Skip Navigation

[Resolved] Reset Cred Field with relationship to placeholder

This support ticket is created 3 years, 1 month 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 3 replies, has 3 voices.

Last updated by Luo Yang 3 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#2234093

I have a cred field in a cred form, that is addressing a relationship:

[cred_field field='@protokoll-festvertrag.parent' class='form-control' output='bootstrap' select_text='--- not set ---' required='false']

The relationship is already set when loading the form/page, so there is a value in the field available after page loaded.
I want to remove the value and reset it to the default placeholder. This is just working by manually clicking the "x", however it is not working using "value" or "urlparam" attributes in the cred_field shortcode.

Could you assist on this? How can I reset the value to placeholder/disconnect the relationship? I need to have it done right after page was loaded. I simply want to click on Submit form to have the relationship disconnected.

Some more background info:
I have many of those forms on one page and want to reset hundreds of relations. I have seen that select2 is being used, however was not able to form the javascript accordingly. Maybe there is another solution less complicated.

BR Bernhard

#2234105

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

If you have a parent post selector in a CRED form for child posts, it would normally only be pre-populated with a parent if you link to the page with the cred_child_link_form shortcode (https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_child_link_form).

That adds a URL parameter to the page URL so that when you land on the page the parent post select field recognises the URL parameter and sets the value accordingly.

Before looking in to this any further, am I understanding correctly that this is the scenario in your case, and that you want to unset the specified parent.

In which case I might ask, why not change how you link to the page, so that you don't specify the parent? (You'll note that is done with the parent_link attribute of the cred_child_link_form shortcode.)

#2234231

Hi Nigel,

sorry for not adding this:
I am talking about editing a form, it is not a new form that creates new posts. That is why the cred field is already pre populated and I want to delete the population to remove the relationship (so, unsetting the specified parent).

BR Bernhard

#2234813

Hello,

You can use relationship form shortcode [cred-delete-relationship] to remove the relationships between posts, see our document:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred-delete-relationship