You are here

function ajax_error_behavior_form_system_logging_settings_alter in AJAX Error Behavior 7

Implements hook_form_FORM_ID_alter().

File

./ajax_error_behavior.module, line 50
Code to provide configuration for different ajax error behaviors.

Code

function ajax_error_behavior_form_system_logging_settings_alter(&$form, &$form_state, $form_id) {
  $form['ajax_error_behavior'] = array(
    '#type' => 'radios',
    '#title' => t('JavaScript behavior for Ajax errors'),
    '#default_value' => variable_get('ajax_error_behavior', 'core'),
    '#options' => array(
      'core' => t('Core'),
      'alert' => t('Alert'),
      'watchdog' => t('Custom alert + watchdog'),
      'console' => t('Console'),
    ),
    '#description' => t('The default behavior is to show an alert except if the error is triggered after browsing away from the page. The other behaviors affect every Ajax error messages.'),
  );
  $form['ajax_error_behavior_error'] = array(
    '#type' => 'textarea',
    '#rows' => 1,
    '#title' => t('Custom alert'),
    '#default_value' => variable_get('ajax_error_behavior_error', t('There was some error in the user interface, please contact the site administrator.')),
    '#description' => t('The default behavior is to show an alert except if the error is triggered after browsing away from the page. The other behaviors affect every Ajax error messages.'),
    '#states' => array(
      'visible' => array(
        ':input[name="ajax_error_behavior"]' => array(
          'value' => 'watchdog',
        ),
      ),
    ),
  );
}