You are here

function webform_validation_manage_overview_form in Webform Validation 7

Form to list and reorder the rules assigned to a webform.

1 string reference to 'webform_validation_manage_overview_form'
webform_validation_manage in ./webform_validation.admin.inc
Menu callback function.

File

./webform_validation.admin.inc, line 101
Manages validation rules administration UI.

Code

function webform_validation_manage_overview_form($form, &$form_state, $rules, $node) {
  $form = array();
  $form['#tree'] = TRUE;
  $validators = webform_validation_get_validators_selection();
  foreach ($rules as $rule) {
    $component_info = webform_validation_rule_components_basic($rule['components']);
    $form[$rule['ruleid']] = array(
      '#type' => 'fieldset',
    );
    $form[$rule['ruleid']]['name'] = array(
      '#type' => 'item',
      '#title' => t('Name'),
      '#markup' => check_plain($rule['rulename']),
    );
    $form[$rule['ruleid']]['validator'] = array(
      '#type' => 'item',
      '#title' => t('Validator'),
      '#markup' => $validators[$rule['validator']],
    );
    $form[$rule['ruleid']]['components'] = array(
      '#type' => 'item',
      '#title' => t('Components'),
      '#markup' => theme('item_list', array(
        'items' => $component_info,
      )),
    );
    $form[$rule['ruleid']]['weight'] = array(
      '#type' => 'weight',
      '#title' => t('Weight'),
      '#default_value' => $rule['weight'],
      '#description' => t('Optional. By changing the order of validation rules, you can use code that relies on earlier validation functions being completed.'),
    );
    $form[$rule['ruleid']]['actions'] = array(
      '#type' => 'actions',
    );
    $form[$rule['ruleid']]['actions']['edit'] = array(
      '#type' => 'item',
      '#markup' => l(t('Edit'), 'node/' . $node->nid . '/webform/validation/edit/' . $rule['validator'] . '/' . $rule['ruleid'], array(
        "query" => drupal_get_destination(),
      )),
    );
    $form[$rule['ruleid']]['actions']['delete'] = array(
      '#type' => 'item',
      '#markup' => l(t('Delete'), 'node/' . $node->nid . '/webform/validation/delete/' . $rule['ruleid'], array(
        "query" => drupal_get_destination(),
      )),
    );
  }
  if (count($rules) > 1) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save rule order'),
    );
  }
  return $form;
}