You are here

function rules_forms_rules_data_info in Rules Forms Support 7.2

Same name and namespace in other branches
  1. 7 rules_forms.rules.inc \rules_forms_rules_data_info()

Implements hook_rules_data_info().

File

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

Code

function rules_forms_rules_data_info() {

  // Base data types for form and form_states.
  $data_info['form'] = array(
    'label' => t('form'),
    'group' => t('Rules Forms'),
    'wrap' => TRUE,
    'wrapper class' => 'RulesFormsFormWrapper',
  );
  $data_info['form_state'] = array(
    'label' => t('form state'),
    'group' => t('Rules Forms'),
    'wrap' => TRUE,
    'wrapper class' => 'RulesFormsFormStateWrapper',
  );

  // Each active form has its own data type with unique property info
  // describing the structure of the form.
  foreach (rules_forms_get_form_info() as $form_id => $info) {
    $data_info[$form_id] = array(
      'label' => $info['label'],
      'group' => t('Rules Forms'),
      'parent' => 'form',
      'property info' => $info['properties']['form'],
      'wrap' => TRUE,
      'wrapper class' => 'RulesFormsFormWrapper',
    );
    $data_info[$form_id . '_state'] = array(
      'label' => t('@form state', array(
        '@form' => $info['label'],
      )),
      'group' => t('Rules Forms'),
      'parent' => 'form_state',
      'property info' => $info['properties']['form_state'],
      'wrap' => TRUE,
      'wrapper class' => 'RulesFormsFormStateWrapper',
    );
  }

  // Provide Rules data types for form elements and their attributes.
  // Each form's property info is made up of form elements types that
  // refer to these data types.
  module_load_include('inc', 'rules_forms', 'includes/rules_forms.info');
  $data_info['form_element'] = array(
    'label' => t('form element'),
    'group' => t('Rules Forms'),
    'wrap' => TRUE,
    'wrapper class' => 'RulesFormsElementWrapper',
    'creation callback' => 'rules_forms_create_element',
  );
  foreach (rules_forms_get_element_info() as $name => $info) {
    $data_info['form_' . $name] = array(
      'label' => $info['label'],
      'group' => t('Rules Forms'),
      'parent' => 'form_element',
      'wrap' => TRUE,
      'wrapper class' => 'RulesFormsElementWrapper',
      'creation callback' => 'rules_forms_create_element',
    );
  }
  return $data_info;
}