You are here

README.txt in Webform Rules 6

Same filename and directory in other branches
  1. 7 README.txt
This module provides basic rules integration for webform.


-- REQUIREMENTS --

You need the following modules for a working feature:

 * Webform (http://drupal.org/project/webform)
   Note: be sure to install at version 6.x-3.x or above.
 * Rules (http://drupal.org/project/rules)

optional:
 * Token (http://drupal.org/project/token)


-- INSTALLATION --

Copy the module files to you module directory and then enable it on the admin
modules page. After that you'll see two new events in the listing while creating
a new rule.


-- USAGE --

Using the submitted data in a rule is easy, as you can access it either via PHP
or using tokens (after installing the Token-module).

PHP:
 Each rule reacting on an event thrown by "Webform Rules" gets 3 arguments to
 work with:
  * $user
     The user object of the acting user (the one, who submitted the webform).
  * $node
     The webform itself.
  * $data
     The submitted webform data and the submission id.
     To get the submission id, use <code><?php print $data['sid']; ?></code>.
     The components of the webform are stored using this structure:
     <code>array(
       '{form_key}' => array(
         'value' => {submitted value},
         'component' => {webform component},
       ),
     )</code>
     Given this structure, you can access the value of a component called
     "email" with
     <code><?php print $data['components']['email']['value']; ?></code>.
    
     Warning:
      This is raw user input! Make sure to run this through check_plain() before
      using it.
    
     Note:
      Some components (for example "grid") return arrays, so 'value' isn't a
      simple string always.

     Modifying submitted data:
      $data is capable of "intelligent saving" meaning you can modify the
      submitted webform data with a rule and save it back to the submission.
      To do so you'll need to assign the new value to the component and return
      the data with <code>return array('data' => $data);</code>
      Example (guessing you have components called "email" and "workdays"):
       <code>
       // Set email to "info@example.com" by default.
       $data['components']['email']['value'] = 'info@example.com';
       // Set workdays from Tuesday to Thursday by default.
       // Component "workdays" is a set of checkboxes in this example.
       $data['components']['workdays']['value'] = array(
         'tuesday', 'wednesday', 'thursday',
       );
       </code>

Token:
 There are 8 pre-defined tokens for the webform data:
  * [data:data]
    This one prints out all data submitted by the webform in the following
    format:
    {form_key}: {label}: {value}
  * [data:data-raw]
    This one does exactly the same as [data:data] with the difference to not
    clean up the values using check_plain().
  * [data:{component}-title]
    This is a dynamic token. "{component}" is a placeholder for the components
    form key (machine readable name). Example: your webform has a component with
    the form key "email". So you would write [data:email-title] to use the title 
    (label) of this field.
  * [data:{component}-value]
    Same as [data:{component}-title], but it returns the value instead of the
    title.
  * [data:{component}-value-html]
    This one does exactly the same as [data:{component}-value] with the 
    difference that its output will be rendered as html.
  * [data:{component}-value-raw]
    This one does exactly the same as [data:{component}-value] with the 
    difference to not clean up the value using check_plain(). This is raw user
    input so take care if you use this somewhere else.
  * [data:{component}-display]
    Returns a combination of [data:{component}-title] and 
    [data:{component}-value] (done by module Webform).
  * [data:{component}-display-html]
    This one does exactly the same as [data:{component}-display] with the 
    difference that its output will be rendered as html.

Condition:
 Webform Rules adds a new condition to the rules configuration. With this
 condition you can tell rules to react only on one specific webform by selecting
 its title.


-- AUTHOR --

Stefan Borchert
http://drupal.org/user/36942
http://www.undpaul.de

File

README.txt
View source
  1. This module provides basic rules integration for webform.
  2. -- REQUIREMENTS --
  3. You need the following modules for a working feature:
  4. * Webform (http://drupal.org/project/webform)
  5. Note: be sure to install at version 6.x-3.x or above.
  6. * Rules (http://drupal.org/project/rules)
  7. optional:
  8. * Token (http://drupal.org/project/token)
  9. -- INSTALLATION --
  10. Copy the module files to you module directory and then enable it on the admin
  11. modules page. After that you'll see two new events in the listing while creating
  12. a new rule.
  13. -- USAGE --
  14. Using the submitted data in a rule is easy, as you can access it either via PHP
  15. or using tokens (after installing the Token-module).
  16. PHP:
  17. Each rule reacting on an event thrown by "Webform Rules" gets 3 arguments to
  18. work with:
  19. * $user
  20. The user object of the acting user (the one, who submitted the webform).
  21. * $node
  22. The webform itself.
  23. * $data
  24. The submitted webform data and the submission id.
  25. To get the submission id, use .
  26. The components of the webform are stored using this structure:
  27. array(
  28. '{form_key}' => array(
  29. 'value' => {submitted value},
  30. 'component' => {webform component},
  31. ),
  32. )
  33. Given this structure, you can access the value of a component called
  34. "email" with
  35. .
  36. Warning:
  37. This is raw user input! Make sure to run this through check_plain() before
  38. using it.
  39. Note:
  40. Some components (for example "grid") return arrays, so 'value' isn't a
  41. simple string always.
  42. Modifying submitted data:
  43. $data is capable of "intelligent saving" meaning you can modify the
  44. submitted webform data with a rule and save it back to the submission.
  45. To do so you'll need to assign the new value to the component and return
  46. the data with return array('data' => $data);
  47. Example (guessing you have components called "email" and "workdays"):
  48. // Set email to "info@example.com" by default.
  49. $data['components']['email']['value'] = 'info@example.com';
  50. // Set workdays from Tuesday to Thursday by default.
  51. // Component "workdays" is a set of checkboxes in this example.
  52. $data['components']['workdays']['value'] = array(
  53. 'tuesday', 'wednesday', 'thursday',
  54. );
  55. Token:
  56. There are 8 pre-defined tokens for the webform data:
  57. * [data:data]
  58. This one prints out all data submitted by the webform in the following
  59. format:
  60. {form_key}: {label}: {value}
  61. * [data:data-raw]
  62. This one does exactly the same as [data:data] with the difference to not
  63. clean up the values using check_plain().
  64. * [data:{component}-title]
  65. This is a dynamic token. "{component}" is a placeholder for the components
  66. form key (machine readable name). Example: your webform has a component with
  67. the form key "email". So you would write [data:email-title] to use the title
  68. (label) of this field.
  69. * [data:{component}-value]
  70. Same as [data:{component}-title], but it returns the value instead of the
  71. title.
  72. * [data:{component}-value-html]
  73. This one does exactly the same as [data:{component}-value] with the
  74. difference that its output will be rendered as html.
  75. * [data:{component}-value-raw]
  76. This one does exactly the same as [data:{component}-value] with the
  77. difference to not clean up the value using check_plain(). This is raw user
  78. input so take care if you use this somewhere else.
  79. * [data:{component}-display]
  80. Returns a combination of [data:{component}-title] and
  81. [data:{component}-value] (done by module Webform).
  82. * [data:{component}-display-html]
  83. This one does exactly the same as [data:{component}-display] with the
  84. difference that its output will be rendered as html.
  85. Condition:
  86. Webform Rules adds a new condition to the rules configuration. With this
  87. condition you can tell rules to react only on one specific webform by selecting
  88. its title.
  89. -- AUTHOR --
  90. Stefan Borchert
  91. http://drupal.org/user/36942
  92. http://www.undpaul.de