Skip Navigation

[Resolved] Set default posts in relationship form

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 16 replies, has 2 voices.

Last updated by aprilB 4 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1786107

branching from this ticket: https://toolset.com/forums/topic/views-within-a-view/
Q1 : Since we know the parent as well that we want to add can you default the parent on the "add-products-to-showrooms-form"? i have read a few tickets that discussed different ways but i have not been able to successfully implement myself.

i have a product and showrooms that are in a many to many relationship.. the single product page has a link to Add the product to a specific showroom. bc we know both the product and the showroom i would like my relationship form to default the parent and the child. Currently it is defaulting the child only.

here is one of the tickets I read and tried to implement: https://toolset.com/forums/topic/set-intermediary-relationships-in-cred-new-post-form/

#1787059

Hello,

I assume we are talking about many-to-many relationship and a Toolset relationship form.

If it is, it is possible to setup the parent post and child post, for example, you can display the relationship form shortcode like this:

[cred-relationship-form form='my-relationship-form-slug' child_item='123' parent_item='456']

Please replace 123 with the specific child post ID, replace 456 with the specific parent post ID,

#1788099

Hi,

I would like to display a link to the form NOT the form itself. i have this in the view:

[cred-relationship-form-link form='add-products-to-showrooms-form' child_item='[wpv-post-id item="$current_page"]' content_template_slug='editing-mode-template-for-showrooms-and-products-relationships']Add to [show-post-title post_id='[wpv-post-id]'] [/cred-relationship-form-link]

if i add parent_item=''[wpv-post-id]' then my page does NOT display.

is this valid?

this was a branch from this ticket if you need background info:
https://toolset.com/forums/topic/views-within-a-view/

thank you...

#1788455

Unfortunately, the [cred-relationship-form-link] shortcode does not support setting attributes "parent_item" and "child_item" both, you can only use one of them.

You can add a feature request for it here:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Our developers will evaluate it.

#1789123

Are there no workarounds? Anyway to set the parent and child?

If not what about a way to just automatically connect the showroom and product from my page without loading the form?

#1789667

hello,

Ok i was able to figure out a way. I added the form to the to my view which is displayed on the product page:

[cred-relationship-form form='auto-add-prod-and-showroom-form' parent_item='[wpv-post-id]' child_item='[wpv-post-id item="$current_page"]']

then on the form i hide the parent and child fields.

ne remaining issue is that i want the button to say "Add to [parent post name]" but i am not sure how to reference this..

this is the form:
hidden link

you can see login details on ticket:
https://toolset.com/forums/topic/setting-up-a-form-to-edit-a-many-to-many-relationship/

i have this
[cred-form-submit field='submit' name='submit']Add to [wpv-post-title] [/cred-form-submit]
and right now it displays the child's post title..

how do i get this to display the parent post title?

thank u!

#1789803

You can display current page post title with "item" attribute, for example:
[wpv-post-title item="$current_page"]

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
$current_page is used to retrieve data from the current page being rendered. It can be used inside a View loop to obtain data from the page on which the View is being rendered.

#1790427
Screen Shot 2020-09-25 at 8.20.50 AM.png

see attachment as I still getting nothing..

this is my form code:
****************************************************
[cred-relationship-form-container]
<div class="form-group" style="display:none;">
<label>Showroom</label>
[cred-relationship-role role='parent' orderby='title']
</div>
<div class="form-group" style="display:none;">
<label>Products</label>
[cred-relationship-role role='child' style='hide { display:none; }']
</div>
<div class="form-group" style="display:none;">
<label>Price</label>
[cred-relationship-field name='price']
</div>
[cred-form-feedback field='feedback' name='feedback']
[wpv-post-id item='@showrooms-product.parent']
[wpv-post-id item="@showrooms-product.child"]
[cred-form-submit field='submit' name='submit']Add to [wpv-post-title item="$current_page"][/cred-form-submit]
[/cred-relationship-form-container]

****************************************************

i would like the submit button to display the post title of the parent in the relationship form. both of the following expressions show "Add to" and are blank:

[wpv-post-title item='@showrooms-product.parent']
[wpv-post-title item="$current_page"]

#1792427

You can setup the submit form shortcode like this:
[cred-form-submit label='Add to [wpv-post-title item="$current_page"]']

More help:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred-form-submit

#1793457
Screen Shot 2020-09-28 at 11.10.18 AM.png

if I use the shortcode you recommend above:

[cred-form-submit label='Add to [wpv-post-title item="$current_page"]']

I get a blank button. it does not even say "Add to". See attachment..

Also, I want the parent name to display so wouldn't it be

[wpv-post-title item='@showrooms-product.parent']

If you see my response last week, I was already trying this:
[cred-form-submit field='submit' name='submit']Add to [wpv-post-title item='@showrooms-product.parent'][/cred-form-submit]

and I tried it with
[cred-form-submit field='submit' name='submit']Add to [wpv-post-title item='$current'][/cred-form-submit]

both display 'Add to' with nothing listed after.

this will though list the child title:
[cred-form-submit field='submit' name='submit']Add to [wpv-post-title][/cred-form-submit]

BUT again i want the parent.

#1793623

I have tried it in my localhost with a fresh WP installation + the latest version of Toolset plugins, it works fine, please check these:

1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS code snippets, and test again

3) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

4) If the problem still persists, please provide database dump file(ZIP file) of your website, you can put the package files in your own google drive disk, share the link only, also point out the problem page URL and form URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1793693

would you like to login to my application? that is what you did before on another bug. seems like a lot less work..

thanks.

#1793709

ok so in checking for updated plugins.. i needed to do a few toolset plugin updates. I am running into a problem. When ii try to install the new forms plugin 2.6 it gives me a critical error on WordPress. I then go into the backend and back the plugin update out and re-install 2.5.8 and it works again.

Also, i added the debug lines as recommended:

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

and nothing is written to my error log file.

please let me know how to proceed.

#1793751

I have enabled the private message box again, please provide your website credentials, also point out:
- the problem page URL
- form URL

Thanks

#1795115

Thanks for the details, I can login your website and see the problem,
I assume we are talking about the submit button of this URL:
hidden link

And the relationship form here:
hidden link

please check these:
1) Dashboard-> Plugins
hidden link
You are using old version of Toolset Forms plugin 2.5.8, there is issue with submit button label, see the change logs:
https://toolset.com/download/toolset-cred/#changelog
Fixed some issues with the Submit button on relationship forms.
So you will need to upgrade to the latest version of Toolset Forms plugin 2.6.

2) Dashboard-> Tools-> Site Health
hidden link
Your website is using PHP 7.0.33, the Toolset Forms plugin 2.6 has a bug with old PHP version(below PHP 7.1.3), it will trigger PHP errors in old PHP version, our developers are working on it, will release a hotfix for it soon.

And according to WP document:
https://wordpress.org/about/requirements/
To run WordPress we recommend your host supports:
PHP version 7.4 or greater.

So before the hotfix is released, currently, please try these:
1) Upgrade your website server PHP to 7.4 and above
2) Upgrade the Toolset Forms plugin to the latest version 2.6
Then test again.