function facetapi_facet_display_form_submit in Facet API 7
Same name and namespace in other branches
- 6.3 facetapi.admin.inc \facetapi_facet_display_form_submit()
- 7.2 facetapi.admin.inc \facetapi_facet_display_form_submit()
Form submission handler for facetapi_facet_display_form().
1 string reference to 'facetapi_facet_display_form_submit'
- facetapi_facet_display_form in ./
facetapi.admin.inc - Form constructor for the facet display settings form.
File
- ./
facetapi.admin.inc, line 819 - Admin page callbacks for the Facet API module.
Code
function facetapi_facet_display_form_submit($form, &$form_state) {
// Pulls variables for code readability.
$adapter = $form['#facetapi']['adapter'];
$realm = $form['#facetapi']['realm'];
$facet = $form['#facetapi']['facet'];
$global_values = $form_state['values']['global'];
unset($form_state['values']['global']);
// Loads settings, saves all form values as settings other than excluded.
$facet_settings = $adapter
->getFacet($facet)
->getSettings($realm);
$facet_settings->settings = array_merge($facet_settings->settings, array_diff_key($form_state['values'], array_flip($form['#facetapi']['excluded_values'])));
$global_settings = $adapter
->getFacet($facet)
->getSettings();
foreach ($global_values as $key => $value) {
$global_settings->settings[$key] = $value;
}
$success = TRUE;
if (FALSE === ctools_export_crud_save('facetapi', $facet_settings)) {
drupal_set_message(t('Error saving configuration options.'), 'error');
$success = FALSE;
}
if (FALSE === ctools_export_crud_save('facetapi', $global_settings)) {
drupal_set_message(t('Error saving configuration options.'), 'error');
$success = FALSE;
}
// Sets message if both sets of configurations were saved.
if ($success) {
drupal_set_message(t('The configuration options have been saved.'));
}
// Redirects back to the realm settings page if necessary.
$clicked = $form_state['clicked_button']['#value'];
if (t('Save and go back to realm settings') == $clicked) {
$form_state['redirect'] = $adapter
->getPath($realm['name']);
}
}