You are here

function ife_settings_form in Inline Form Errors 7.2

Same name and namespace in other branches
  1. 6.2 ife.settings.inc \ife_settings_form()
  2. 6 ife.settings.inc \ife_settings_form()
  3. 7 ife.settings.inc \ife_settings_form()

IFE settings form.

1 string reference to 'ife_settings_form'
ife_menu in ./ife.module
Implements hook_menu().

File

./ife.settings.inc, line 11
Admin settings pages.

Code

function ife_settings_form($form, $form_state) {
  $form = array();
  $form['#variable_edit_form'] = TRUE;

  // General options.
  $form['general_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('General options'),
    '#collapsed' => FALSE,
    '#collapsible' => FALSE,
  );
  $form['general_settings']['ife_show_form_ids'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show form_ids on form'),
    '#description' => t('This option will print the form_id on the form for users with the administer inline form errors permissions'),
    '#default_value' => variable_get('ife_show_form_ids', 0),
  );
  $form['general_settings']['ife_show_everywhere'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show everywhere'),
    '#description' => t('This option will show inline form errors on all forms. You can ignore all settings in the form conversion fieldset.'),
    '#default_value' => variable_get('ife_show_everywhere', 0),
  );
  $form['general_settings']['ife_display'] = array(
    '#type' => 'select',
    '#title' => t('Default display settings'),
    '#description' => t('What do you want to do with the original messages block at the top of the page?'),
    '#options' => array(
      t('Leave the messages in place (default Drupal behavior)'),
      t('Show an alternate error message (a general error message of your choice)'),
      t('Remove all messages (Show nothing)'),
    ),
    '#default_value' => variable_get('ife_display', IFE_MESSAGE_ALTERNATE),
  );
  $form['general_settings']['ife_position_inline_message'] = array(
    '#type' => 'radios',
    '#title' => t('Inline error message position'),
    '#description' => t('The position of the inline error message is relative to the element. Custom type imply that developer is responsible for the output of an error in the right place.'),
    '#default_value' => variable_get('ife_position_inline_message', IFE_POSITION_INLINE_MESSAGE_AFTER),
    '#options' => array(
      IFE_POSITION_INLINE_MESSAGE_BEFORE => t('Before'),
      IFE_POSITION_INLINE_MESSAGE_AFTER => t('After'),
      IFE_POSITION_INLINE_MESSAGE_CUSTOM => t('Custom'),
    ),
  );
  $form['general_settings']['ife_general_message'] = array(
    '#type' => 'textarea',
    '#title' => t('General error message'),
    '#description' => t('A general error message to display at the top of the page (default Drupal messages display). For use with the option "Show an alternate error message".'),
    '#default_value' => variable_get('ife_general_message', 'Please correct all highlighted errors and try again.'),
    '#required' => TRUE,
  );

  // The form_id's.
  $form['form_ids'] = array(
    '#type' => 'fieldset',
    '#title' => t('Form conversion'),
    '#collapsed' => FALSE,
    '#collapsible' => FALSE,
    '#tree' => TRUE,
    '#theme' => 'ife_settings_form_ids',
  );
  $form_ids = ife_load_form_ids(TRUE);
  foreach ($form_ids as $form_id) {
    $form['form_ids'][$form_id->form_id] = array();
    $form['form_ids'][$form_id->form_id]['form_id'] = array(
      '#markup' => $form_id->form_id,
    );
    $form['form_ids'][$form_id->form_id]['field_types'] = array(
      '#markup' => t('All fields will be converted'),
    );
    $form['form_ids'][$form_id->form_id]['status'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enabled'),
      '#default_value' => $form_id->status,
    );
    $form['form_ids'][$form_id->form_id]['display'] = array(
      '#type' => 'select',
      '#options' => ife_message_display_options(),
      '#default_value' => $form_id->display,
    );
  }
  $form['form_ids']['new_form_id']['form_id'] = array(
    '#type' => 'textfield',
    '#description' => t('The "*" character is a wildcard. Ex. webform_*.'),
    '#size' => 20,
  );
  $form['form_ids']['new_form_id']['status'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enabled'),
    '#default_value' => 1,
  );
  $form['form_ids']['new_form_id']['field_types'] = array(
    '#value' => t('All fields will be converted'),
  );
  $form['form_ids']['new_form_id']['display'] = array(
    '#type' => 'select',
    '#options' => ife_message_display_options(),
    '#default_value' => IFE_MESSAGE_DEFAULT,
  );
  $form['#submit'][] = 'ife_settings_form_submit';
  return system_settings_form($form);
}