function cer_settings_form_submit in Corresponding Entity References 7.2
Same name and namespace in other branches
- 7 cer.admin.inc \cer_settings_form_submit()
Submit function for settings form.
File
- ./
cer.admin.inc, line 69 - Administrative functionality, separated for performance purposes.
Code
function cer_settings_form_submit($form, $form_state) {
ctools_include('export');
$query_values = array();
$mapping = unserialize($form_state['values']['mapping']);
foreach ($form_state['values'] as $key => $value) {
$keys = explode('_', $key);
if ($keys[0] == 'enabled') {
$query_values[$mapping[$keys[1]]] = $value;
}
}
// load all existing presets
$presets = ctools_export_crud_load_all('cer');
foreach ($query_values as $key => $value) {
// get preset object (create new one if it doesn't exist already).
$preset = empty($presets[$key]) ? ctools_export_crud_new('cer') : $presets[$key];
// set and save value
if (empty($preset->entity_types_content_fields)) {
$preset->entity_types_content_fields = $key;
}
$preset->enabled = $value;
ctools_export_crud_save('cer', $preset);
// remove from list of presets, so we know which ones are still used
if (isset($presets[$key])) {
unset($presets[$key]);
}
}
drupal_set_message(t('The configuration has been saved.'));
}