2

I have a form using #states which is great, but once a hidden field is made visible I would like the user to be able to hide it again by clicking a close button, rather than deselecting the original checkbox - hopefully by triggering the original states function. Is there a Drupal way to do this?

1
  • u can use jquery to fix your problem.
    – cobenash
    Oct 3, 2012 at 6:39

2 Answers 2

2

If "#edit-radiobutton" should launch the state, just do:

jQuery('#edit-radiobutton').click().trigger('change');
1
  • Might be a jQuery version thing, I needed jQuery('#edit-radiobutton').click().change();
    – Duncanmoo
    Mar 15, 2018 at 13:59
0

What I understand is that you unhide a field using #states, and want the end user to hide it again. If thats the case, there is no way you can do this in drupal. You can use Jquery to do so, use .hide() function to hide that particular div.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.