You are here

function beautytips_manager_custom_styles_form_submit in BeautyTips 7.2

Submission callback on beautytips_manager_custom_styles_form.

File

./beautytips_manager.admin.inc, line 460
Administration pages and forms for beautytips manager.

Code

function beautytips_manager_custom_styles_form_submit($form, &$form_state) {
  $style = new stdClass();
  $style->name = $form_state['values']['name'];
  $mapping = beautytips_manager_style_mapping();
  foreach ($form_state['values']['custom_styles'] as $custom_style => $value) {
    if (!is_array($value)) {
      $field = $custom_style;
      if (isset($mapping['options'][$custom_style])) {
        $style->{$mapping['options'][$custom_style]} = $value;
      }
    }
    else {
      if ($custom_style == 'css-styles') {
        foreach ($value as $css_style => $css_value) {
          if (isset($mapping['css_options'][$css_style])) {
            $style->{$mapping['css_options'][$css_style]} = $css_value;
          }
        }
      }
    }
  }
  if (!is_null($form_state['values']['style'])) {
    $style->id = $form_state['values']['style']->id;
  }
  beautytips_manager_save_custom_style($style);
  cache_clear_all('beautytips:beautytips-styles', 'cache');
  $form_state['redirect'] = 'admin/config/user-interface/beautytips/custom-styles';
}