You are here

function file_style_form_submit in Styles 7.2

Same name and namespace in other branches
  1. 7 contrib/file_styles/file_styles.admin.inc \file_style_form_submit()

Submit handler for saving a file style.

File

contrib/file_styles/file_styles.admin.inc, line 295
Administrative page callbacks for the File: Styles module.

Code

function file_style_form_submit($form, &$form_state) {

  // Update the file style name if it has changed.
  $style = $form_state['file_style'];
  if (isset($form_state['values']['name']) && $style['name'] != $form_state['values']['name']) {
    $style['name'] = $form_state['values']['name'];
  }

  // Update file effect weights.
  if (!empty($form_state['values']['effects'])) {
    foreach ($form_state['values']['effects'] as $meid => $effect_data) {
      if (isset($style['effects'][$meid])) {
        $effect = $style['effects'][$meid];
        $effect['weight'] = $effect_data['weight'];
        file_effect_save($effect);
      }
    }
  }
  file_style_save($style);
  if ($form_state['values']['op'] == t('Update style')) {
    drupal_set_message('Changes to the style have been saved.');
  }
  $form_state['redirect'] = 'admin/config/file/file-styles/edit/' . $style['name'];
}