Support › Meta Box Conditional Logic › [Feature Request] Conditionally Set Value Of Field Based On Value Of Another
It would be nice to have the ability to set conditional logic to change the value of a field based on the value of another field. Similar to this topic:
I know this can be coded, but instead of having to code it, it'd be nice to have the ability to set this up through the conditional logic interface.
For instance, I have a button group of 2 buttons and conditions set to show 1 of 2 text fields depending on the button selected.
For this use case, I want to allow users to save data in text field #1 [OR] text field #2, depending on the button they select. I do not want them to be able to save data in both.
This is how things currently work:
1. I set up a button group with two buttons
2. I set up two text fields, each shown depending on the selected button.
3. Let's assume the user selects button #1 to show text field #1 (text field #2 remains hidden), and the user then adds data to text field #1.
4. The user then selects button #2, which shows text field #2 (and hides text field #1), and then adds data to text field #2.
5. At this point, there is data in both text field #1 and text field #2.
6. When the user saves the post, the data in both text field #1 and text field #2 will be saved to the database.
This may work fine in many use cases, but there are cases (in this example) where if the user adds data to one of the text fields, we want to ensure that the other text field is set to empty/NULL or even some other value.
I'm sure there are also many other use cases where one field's value might depend on another's value.
I understand this can be accomplished with code, which I'm currently doing. But, it would be nice (from a usability perspective) to have an interface in the Meta Box Builder that allows for conditionally setting the values of fields based on the values of other fields.
Hopefully, you can add this feature request to your roadmap.
Thank you for your suggestion.
Currently, Meta Box Conditional Logic only supports showing/hiding fields based on the value of other fields. It does not support settings/changing the value of a field based on the value of other fields like that. I will inform the development team to consider supporting this feature in future updates.