Disable (delete) fields that are hidden conditionally?
Support › MB Conditional Logic › Disable (delete) fields that are hidden conditionally?Resolved
- This topic has 5 replies, 4 voices, and was last updated 3 years, 5 months ago by
John Chvatal.
-
AuthorPosts
-
August 30, 2018 at 10:57 PM #11179
calebcook
ParticipantI want to use conditional logic to actually remove/empty/disable a field, rather than just hide it from view. I notice that if you enter a value in the field and it is hidden later with CL, it still saves in the meta database.
My current scenario for needing this (among others) is with address entries. 99% of the addresses are US-based, so I have a select box with the US States. However, if another country is selected, CL will hide the select box, and show a text field for text entry. The issue is that I have both fields saved, so if I were to select a state, then change the country, I can potentially have two fields for the State (or Province/Region)
How can I disable or empty one field if it is hidden with CL?
August 31, 2018 at 12:42 AM #11183calebcook
ParticipantAlso - on the same topic, found a bug or unexpected behavior. I have the address fields bound to the Geolocate results - so they populate the country/city/etc. However, if a change is made in a box, Conditional Logic does not react to the changes unless another manual change is made.
Scenario: CL will show/hide a select box of US States, based on whether US is selected as the country. However, if the country is changed by Geolocation binding, the CL does not trigger and make the change.
September 1, 2018 at 2:53 PM #11215Anh Tran
KeymasterHello,
Unfortunately, at the moment, CF only hides the fields. Clearing the values might lead to another unexpected behavior: users enter data in field A, and then hide it. After that, they changed their mind and show it. And they might expect the value they already entered.
Let me work on the JS. I think I can add a custom JS event to the field when it's hid, so you can clear the value yourself. This is my idea:
$( 'input' ).on( 'cl_hide', function() { this.value = ''; } );Regarding the issue with Geolocation, I'll check and update. Thanks for letting me know.
September 5, 2018 at 12:56 AM #11245mgratch
Participant@calebcook I think this is based on something I got in the forum, but it looks through group field values being saved and removes empty values that are not visible upon submission.
September 18, 2018 at 5:38 PM #11378Anh Tran
KeymasterHi again,
We've just added the trigger
cl_hidefor inputs when they're hid. Now you can use the snippet I posted above. Please update.May 11, 2022 at 6:23 AM #35977John Chvatal
ParticipantAnh, how do I get this working? Where do I add this code?
I have a member survey that has the first 6 fields set to hide questions. I need to delete the hidden field data when a logged in user saves the form.
-
AuthorPosts
- You must be logged in to reply to this topic.