You are here

function responsive_menus_admin_form_submit in Responsive Menus 7

Submit handler for responsive_menus_admin_form.

1 string reference to 'responsive_menus_admin_form_submit'
responsive_menus_admin_form in ./responsive_menus.module
Admin settings form for which menus to responsify.

File

./responsive_menus.module, line 282
Responsify menus in Drupal.

Code

function responsive_menus_admin_form_submit($form, &$form_state) {

  // Exclude unnecessary elements.
  form_state_values_clean($form_state);

  // Which field types to run filter_xss() on.
  $filter_types = array(
    'textfield',
    'textarea',
  );
  foreach ($form_state['values'] as $key => $value) {
    if (is_array($value) && isset($form_state['values']['array_filter'])) {
      $value = array_keys(array_filter($value));
    }
    if ($key == 'responsive_menus_style_settings') {
      foreach ($value as $style_key => $style_value) {

        // If the field is a type we should filter.
        if (in_array($form['responsive_menus_style_settings'][$style_key]['#type'], $filter_types, TRUE)) {
          variable_set($style_key, filter_xss($style_value));
        }
        else {
          variable_set($style_key, $style_value);
        }
      }
    }
    else {
      variable_set($key, $value);
    }
  }

  // Clear libraries cache if Sidr style in use to allow theme to be updated.
  if ($form_state['values']['responsive_menus_style'] == 'sidr') {
    cache_clear_all('*', 'cache_libraries', TRUE);
  }
  drupal_set_message(t('The configuration options have been saved.'));
}