You are here

function search_api_saved_searches_index_edit_submit in Search API Saved Searches 7

Form submission handler for search_api_saved_searches_index_edit().

See also

search_api_saved_searches_index_edit()

search_api_saved_searches_index_edit_vaidate()

File

./search_api_saved_searches.admin.inc, line 562
Admin UI functions and form callbacks for saved searches.

Code

function search_api_saved_searches_index_edit_submit(array $form, array &$form_state) {
  $values = $form_state['values'];
  $settings = $form_state['settings'];
  $options = $values['options'];
  if ($options['set_interval'] == 0) {
    $options['set_interval'] = $options['set_interval_custom'];
  }
  unset($options['set_interval_custom']);
  $options['manual']['fields'] = array_keys(array_filter($options['manual']['fields']));
  $settings->enabled = $values['enabled'];
  $settings->options = $options;
  $ret = $settings
    ->save();
  if ($ret === FALSE) {
    drupal_set_message('An error occurred while trying to save the settings. Check the logs for details.', 'error');
    $form_state['rebuild'] = TRUE;
  }
  else {
    drupal_set_message('The settings were successfully saved.');
  }
}