You are here

function admin_menu_theme_settings_validate in Administration menu 7.3

Same name and namespace in other branches
  1. 8.3 admin_menu.inc \admin_menu_theme_settings_validate()

Form validation handler for admin_menu_theme_settings().

File

./admin_menu.inc, line 770
Menu builder functions for Administration menu.

Code

function admin_menu_theme_settings_validate(&$form, &$form_state) {

  // Change the configured components to Boolean values.
  foreach ($form_state['values']['admin_menu_components'] as $component => &$enabled) {
    $enabled = (bool) $enabled;
  }

  // Validates that the font size is valid.
  if (!empty($form_state['values']['admin_menu_font_size'])) {
    $font_size_raw = $form_state['values']['admin_menu_font_size'];
    $allowed_units = array(
      'em',
      '%',
      'px',
    );
    $font_size_base = str_replace($allowed_units, '', $font_size_raw);
    if ($font_size_base === $font_size_raw) {
      form_set_error('admin_menu_font_size', t('The font size unit must be specified with px, em, or %.'));
    }
    if (!is_numeric($font_size_base) || $font_size_base <= 0) {
      form_set_error('admin_menu_font_size', t('The font size base value must be a positive number.'));
    }
  }
}