You are here

function rules_forms_element_variables in Rules Forms Support 7

Adds element variables for the form.

Each form element ID is passed as a variable to the rule for access in conditions and actions. This allows us to provide a select list of elements rather than having to cut-and-paste element IDs.

1 call to rules_forms_element_variables()
rules_forms_rules_event_info in ./rules_forms.rules.inc
Implements hook_rules_event_info().

File

./rules_forms.rules.inc, line 100
Rules events, conditions, and actions hooks for Rules Forms module.

Code

function rules_forms_element_variables($form_id) {
  $variables = array();
  $form_info = rules_forms_get_form_info($form_id);
  if (isset($form_info['elements']) && is_array($form_info['elements'])) {
    foreach ($form_info['elements'] as $key => $info) {
      $variables[$key] = array(
        'type' => 'form_element',
        'label' => $info['label'],
      );
      if (isset($info['options'])) {
        $variables[$key]['options'] = $info['options'];
      }
    }
  }
  return $variables;
}