Is there a way to use the values of form fields when defining an action for a form submission?
The scenario is that I want to send an email message to different people depending on the entered values on a form (easy to do with the Rules module). But I want to include the actual content of the form in the email message which doesn't appear to be possible.
There are tokens for the form state listed in the Token replacement patterns fieldset, but no options are listed for accessing individual form fields contained within the form state.
Is this possible and I'm just not using the correct token format or does this feature need to be added to the rules module?
Thanks.
Comments
Comment #1
thijsvdanker commentedI was wondering the same thing.
Comment #2
hixster commented+1 for some help on this - I was wondering the same thing and posted an issue here http://drupal.org/node/994496 , then found this post.
I can see the tokens on the form elements, but can't see them in the action...
Comment #3
hixster commentedmight need this, token have just been added http://drupal.org/project/issues/webform_rules
Comment #4
Anonymous (not verified) commentedthis is a bug for me
Comment #5
kbk commentedNot sure if this is helpful but have you tried both the Raw and Formatted version of the same fields? If this is pertinent and helps check out this thread: #432518: Tokens are not being replaced with a value in a Rules action for taxonomy term update
Comment #6
fagoThis is a feature request, not a bug.
Comment #7
orbmantell commentedI am having the same problem, please explain how to find what tokens are available.
Comment #8
dbassendine commentedThe $form and $form_state tokens are also missing for rule conditions. In my case, I am trying to doing a textual comparison between form fields at the validation stage of a form submission (using rules_forms). However, this is not possible because the form_state tokens are not available.
For actions and conditions that act on the node after it has been saved, you can work around this by adding a ruleset that loads the node content by nid (see http://drupal.org/node/596230#comment-3638694). However, obviously this doesn't work for form validation, as the node hasn't been saved yet (nor do you want it to be).
Although I'm not really familiar with the Rules or Token API, I did do some digging. It seems to me that in rules_forms_rules_data_type_info (rules_forms.rules.inc) the form and form_state types are declared without an associated "token type" (and so default to "form" and "form_state" respectively - see http://drupalcontrib.org/api/drupal/contributions--rules--rules--rules.a...). Don't we need to define a new token type that maps the values in the form_state array to a series of tokens - just as token does for the "user" or "node" types? Is this already in place, or is it a key piece of architecture that's blocking this feature? Or have I missed something?
NB. The Form ID tokens appear to work well just because there's only a single one-dimensional value, and not an array as for for $form or $form_state.
Any ideas or pointers would really be appreciated. Without this there's really no contrib module that handles form validation outside webforms (I am looking forward to the Field Validation module in d7 though).
Thanks, David
Comment #9
tr commentedDrupal 6 end-of-life was more than two years ago - there will be no new feature in D6 Rules, and D6 Rules is no longer supported.
That said, this could go into Rules for D7 or D8 if someone is willing to contribute code or fund the development of this feature.
Comment #10
tr commented