You are here

function rules_forms_admin_events in Rules Forms Support 7

Same name and namespace in other branches
  1. 7.2 includes/rules_forms.admin.inc \rules_forms_admin_events()

Defines the forms events settings form.

1 string reference to 'rules_forms_admin_events'
rules_forms_menu in ./rules_forms.module
Implements hook_menu().

File

includes/rules_forms.admin.inc, line 11
Administrative forms for Rules Forms module.

Code

function rules_forms_admin_events($form, &$form_state) {
  $form = array();
  $form['general_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('General settings'),
    '#collapsible' => TRUE,
  );
  $form['general_settings']['enable_form_activation_message'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable event activation messages on forms'),
    '#default_value' => isset($_SESSION['rules_forms_message']) ? $_SESSION['rules_forms_message'] : FALSE,
    '#description' => t('When checked, a message is shown on every form containing a link to activate events for that form. This message will only be visible for this session.'),
  );
  $form['general_settings']['enable_form_element_info'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable form element inspection tool'),
    '#default_value' => isset($_SESSION['rules_forms_element_info']) ? $_SESSION['rules_forms_element_info'] : FALSE,
    '#description' => t('If checked, the information about each form element will be displayed in popups on active forms. This tool can be used to inspect existing attributes of form elements for determining what actions to take in your rules. Only visible for your currently logged in user account.'),
  );
  $form['general_settings']['settings_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
    '#submit' => array(
      'rules_forms_settings_submit',
    ),
  );
  $form_info = rules_forms_get_form_info();
  if (!empty($form_info)) {
    $options = array();
    foreach ($form_info as $form_id => $info) {
      $options[$form_id] = $info['label'];
    }
    $form['active_forms'] = array(
      '#type' => 'fieldset',
      '#title' => t('Active forms'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['active_forms']['form_events'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Events enabled forms'),
      '#options' => $options,
      '#description' => t('Forms currently changeable by associated events. You may prevent associated events from changing forms by selecting them and clicking on "Deactivate events".'),
    );
    $form['active_forms']['events_deactivate'] = array(
      '#type' => 'submit',
      '#value' => t('Deactivate events'),
      '#submit' => array(
        'rules_forms_events_deactivate_submit',
      ),
    );
    $form['form_elements'] = array(
      '#type' => 'fieldset',
      '#title' => t('Form elements'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#description' => t('Rules Forms Support stores information about the elements native to active forms. To rebuild the stored information about a form, select a form the select list below.'),
    );
    $form['form_elements']['reset_form'] = array(
      '#type' => 'select',
      '#title' => t('Rebuild form elements'),
      '#options' => $options,
    );
    $form['form_elements']['reset_elements'] = array(
      '#type' => 'submit',
      '#value' => t('Rebuild'),
      '#submit' => array(
        'rules_forms_elements_rebuild',
      ),
    );
  }
  else {
    drupal_set_message(t('To start creating form rules enable the "Enable event activation messages on forms" setting below and navigate to the form you would like to activate events for.'), 'status', FALSE);
  }
  return $form;
}