Skip Navigation

[Résolu] Post Form Conditional Display Group to test empty value

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: I would like to use a Conditional Group in Forms to test whether or not a custom field value is empty, but the conditional does not seem to work correctly.

Solution: You can omit the quotation marks from the condtion to test an empty value.

This support ticket is created Il y a 3 années et 4 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 réponses, has 2 voix.

Last updated by Robert Campbell Il y a 3 années et 4 mois.

Assisted by: Christian Cox.

Auteur
Publications
#1860571
conditional display group.jpg

I have a fairly long Post Form so I want to hide a number of the form fields unless certain earlier form fields have content. As an example:

I have a post form field called 'room1-name'

I want to display another group of fields only if 'room1-name' has some content entered by the user.

I tried the condition group settings in the attached image but it does not work. Can you advise what to do please.

Regards

Robert

#1860817
Screen Shot 2020-11-29 at 3.40.18 PM.png

Hello, you can omit the quotation marks inside the Value field configurations, as shown in the attachment here. Just an empty value field is fine. The conditional block supports nested elements, so you will drag the content you want displayed conditionally into the conditional block. In my example here, there is a custom HTML block inside the Conditional block contents, so the HTML block will only be displayed if the field is not empty.

Let me know if you have issues with this setup, and I can take a closer look.

#1860867

Hi Christian

Thanks for the advice. I omitted the quotation marks inside the Value field and it starting working. One more question please.

In your example, is there any way for the hidden elements to be revealed as you begin to type into the field which controls where the block is hidden or displayed? I mean without having to click away first?

Regards

Robert

#1861509

Hello again Christian

I have had a further issue with the post form conditional display function.

When I programme a conditional display block in the form and save the form, the conditional display works correctly.

However, if I save the form again (irrespective of whether I make changes to the form or not) then none of the conditional display blocks work.

To make them work again, I have to:-

Bring all of the fields out of the conditional display block wrapper, then put them back in again, and save the form. Then the conditional blocks start to work again.

I have checked out this issue on two separate post forms and the problem is repeatable as described above.

Could you let me know if you can recreate this issue on your own system?

If not, can I give you access to my system to check out the problem please.

I am running Toolset Forms V2.6.2

Regards

Robert

#1861725

In your example, is there any way for the hidden elements to be revealed as you begin to type into the field which controls where the block is hidden or displayed? I mean without having to click away first?
The Forms conditional system is triggered by an input change event, not a keyup or keydown event. It's a technical concept but if you're comfortable writing custom JavaScript you may be able to work around this by triggering a change event upon the keyup or keydown event to trigger the conditional logic. Since there is no public JavaScript API for Forms, that code is outside the scope of our support forums.

However, if I save the form again (irrespective of whether I make changes to the form or not) then none of the conditional display blocks work....Could you let me know if you can recreate this issue on your own system?
Yes, unfortunately this is a known issue that has not yet been fully resolved. The fix for this issue will be included in Forms 2.6.4, but I don't have a release date available yet for that update. Until then, your workaround sounds like the best temporary fix. You can subscribe to updates in this erratum: https://toolset.com/errata/conditionally-hidden-fields-in-toolset-forms-are-removed-from-the-drag-and-drop-editor-if-you-edit-the-form/

#1861749

Hi Christian
Thanks for your explanation about what triggers the conditional event.
And thanks for confirming that there is issue with the conditional display in forms. I have added my voice to the link your supplied.
Regards
Robert

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.