Skip Navigation

[Resolved] Display field conditionally in relationship form using select option

This support ticket is created 3 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/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Waqar 3 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#2213089
Screenshot (57).png

Tell us what you are trying to do? With your help, I created a custom select box to show all of my options, via a shortcode. It is pulling in posts and creating a relationship using those. I would like for the user to be able to select "Other" and put in a new value if they do not see what they want. I suppose I could append an "Other" option to the select box and then include some jQuery to show the "If you chose "other" please specify" field based on an id, but I'm wondering if there is a way I can create a post called "Other" and use a conditional shortcode?

Is there any documentation that you are following? Here is my previous support ticket: https://toolset.com/forums/topic/post-relationship-form-select-only-showing-10-items/
https://toolset.com/documentation/programmer-reference/forms/cred-conditional-display-engine/
https://toolset.com/course-lesson/using-toolset-conditional-block/

I have registered my shortcode under settings. Here is the code from the form:
<div id="new-search" class="form-group new-search">
<label class="select-label">Search or select a system</label>
[create_ehr_parent_field]
</div>
<div class="form-group new-search">
<label>If you chose “Other,” please specify.</label>
[cred-relationship-field name='other']
</div>

What is the link to your site? hidden link

#2213553

Hi,

Thank you for contacting us and I'd be happy to assist.

Including the "Other" option in the list would make the setup complicated and you'll have to add fairly complex customizations to make this work.

A simpler approach would be that above the form you can add note for visitors that if you don't see the desired system in the dropdown list you can use the add new form to add a new system (ehr post).

This form can be on the same page or on a separate page and once a visitor has saved a new entry, it will also become available in the dropdown.

regards,
Waqar

#2214187

Hi Thank you for that idea. I'll go with something like that. I would like to know how to user conditional logic with the select dropdown, so if the user selects a certain EHR, what conditional shortcode can I put in to make that work? I tried [wpv-conditional if=" ( ( '[create_ehr_parent_field post_id]' eq '4023' ) ) " ][/wpv-conditional] but it isn't working. How can I change that to show another text box based on a selection?

#2215883

Thanks for writing back.

I see that you've "Other" as a post option in the systems dropdown list.

The "wpv-conditional" is not useful in this case, because it can be used to show some content based on the fixed values from the server-side, before the page loads. It can't be used to show/hide the content based on the user's selected values on the front-end.

For the front-end form values "cred_show_group" shortcode is available, but that can be used in the post forms and not the relationship forms.
( ref: https://toolset.com/documentation/programmer-reference/forms/cred-conditional-display-engine/ )

To show some content when the "Other" option is selected, you'll need some additional custom script, but that will not end your challenges, because then in the hidden relationship field for systems, "Other" post will also be selected and if the user submits the form as it is, then an unwanted connection with the "Other" post will be created.

This is the reason, I recommended against the idea of including the "Other" option in the systems list.