Skip Navigation

[Resolved] Relational rules

This support ticket is created 6 years, 4 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Author
Posts
#1030216

Hey Guys,

Ok so plain and simple, I have a couple of fields, which need to be related... But the relationships behave a bit wierd.
If "Other" is checked on a checkbox for example, the "More Info" section needs to enable, If it is not checked, the "More Info" section (usually a text-area) needs to clear it's content and disable.

This cannot happen on page load though. it needs to happen as the form is being used?

Also, I need to somehow create sections, And if a section's N/A is checked (checkbox) it needs to do the same, except with all input's below it only... Maybe even hide the whole section or create a overlay not allowing editing?

The second I think is unrealistic to achieve without custom JS, but is the first possible (and possibly the second)?

#1069102

Nigel
Supporter

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

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

Hi Marcel

What you are describing relates to the conditional display of fields on a form.

You can set conditions for displaying fields when you define the custom fields in Types, and these will be inherited when adding the same fields to a Toolset Form, so that the conditions apply both on the front-end and the back-end.

See https://toolset.com/documentation/user-guides/types-custom-fields-conditional-display/

You can also conditionally display sections of your form based upon the values of some field, as described here: https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/

But these conditions simply affect the visibility of content, nothing else.

So in your first example you could hide the more info section with the above techniques, but not clear it.

The second example, hiding whole sections depending on whether a checkbox is checked, yes, that is covered by the second example.

So the only thing missing is clearing field values when they are hidden.

If you must have that then you would need to write your own JS to use in place of the conditional display option available with Toolset.

#1069245

Is there some way to trigger it at the appropriate time?
Basically to check if toolset says it should be hidden then hide is with JS, the hiding and clearing is not an issue... The issue lies in determining when it should be empty, and what field it should be checking the input against... Which is obviously setup in toolset already

#1069284

Nigel
Supporter

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

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

Sorry, I don't understand.

Whether you set up conditional display for individual fields (when setting up the custom fields in Types) or for sections of a form, it works the same way.

Some JavaScript is added to the page which listens for changes in the values of the custom fields which are set to trigger the conditional display of other parts of the form, so that if a field is checked other content which depends on that field is revealed, and if the field is unchecked the other content is hidden.

You can have more sophisticated conditions, but that it basically how it works.

I didn't follow what you meant in your last update.

#1069285

Sorry let me explain better. So lets say I have a rule if Combobox1's value is "Marcel" then input 2 must be hidden. Else it shows...
Your toolset can handle that rule and on page reload it does enforce the rule, but how can i force it to update using javascript?
Is there a way for me to check the toolset rules and update the form using JS without writing a command for every rule setup in toolset?

Do you understand?
Basically I want a way to enforce JS commands with toolset, but I want to use toolset's rules in the toolset so that if we update rules, it does not need to update twice.

#1070030

Nigel
Supporter

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

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

"Your toolset can handle that rule and on page reload it does enforce the rule, but how can i force it to update using javascript?"

Page reload?

The conditional display is already based on JavaScript and doesn't require any reloading of the page, changing fields will automatically affect the visibility of dependent fields or sections, no page reload required.

Using the wpv-conditional shortcodes is something else, which does require page reloads to take effect as it is server-based, but the links I shared above are about JavaScript-based conditional display.