Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I want to hide a text field - for eg. movie_name based on the value of Heirarchichal Select. I have tried using
$form['field_movie_name']['#states'] = array (
'visible' => array ( // action to take.
'select[name="field_category[und][hierarchical_select][selects][1]"]' => array('value' => '298'),
),
);
in hook_node_form_alter where field_category is the taxonomy field with heirarchichal select. The value to compare is child taxonomy term. Is it possible to use #states or should we use Jquery for it?
Comments
Comment #2
saurabh.dhariwal CreditAttribution: saurabh.dhariwal at AddWeb Solution Pvt. Ltd. commentedYes, it is possible to use #state or jQuery as below code:
1. Using #state code as following:
2. Using jquery code to admin theme jquery as below code:
Hope this helps you.
Thanks!
Comment #3
stefan.r CreditAttribution: stefan.r commentedThanks! @zack.wd does this answer your question?
Comment #4
zack.wd CreditAttribution: zack.wd commentedI couldn't get #states to work with Heirarchichal Select as you wrote...I had to use the jquery method..anyway thanks @saurabh.dhariwal ..
Comment #5
saurabh.dhariwal CreditAttribution: saurabh.dhariwal at AddWeb Solution Pvt. Ltd. commentedGlad to hear that any of my provided solution worked for you. Let me know if you face any further Drupal related queries. Ready to help always :)
Thanks
Saurabh
Comment #6
stefan.r CreditAttribution: stefan.r commentedComment #7
temkin CreditAttribution: temkin at SiteCraft commentedSee this issue for #states support with HS module.