Hi guys,
I have taken a close look at the API description page at:
https://api.drupal.org/api/rules/rules.api.php/function/hook_rules_actio...
and was wondering whether it would be possible to add any property to declare a dependency between fields in the 'parameter' section, pretty much the same way ctools does for #dependency, used extensively in the views forms, or even the #states Form API attribute:
http://api.drupal.org/api/drupal/developer%21topics%21forms_api_referenc...
Use case is pretty simple here, for example, hide/display a textfield or checkbox if another checkbox is unchecked/checked, for a parameter on a rules action form, for example. Views does that very well for the fields/filters/sorts settings forms, for example.
I would assume this would come as a feature request, but I just wanted to know if anybody would have an idea about that.
Perhaps a work-around, a work in progress, or any idea to share about this issue.
Any comments or feedback on this particular request would be highly appreciated.
Thanks in advance.
Comments
Comment #1
TR CreditAttribution: TR commentedComment #2
TR CreditAttribution: TR commentedThere's some direct support for this in the Rules action definition hook
hook_rules_action_info()
, using thecallbacks
key. You can also do this by usinghook_form_alter()
along with the full power of the Drupal Form API to modify/enhance the forms generated by Rules. Look atrules_action_data_calc_form_alter()
for an example, where Ajax is used to modify the options of the data_calc action based on other form selections.Examples of both way of altering the form may be found in modules/data.rules.inc
Comment #3
DYdave CreditAttribution: DYdave at CGI commentedThanks a lot Tim, for your kind reply and taking the time to answer.
Cheers!