function nodeformsettings_settings_submit in Node and Comments Form Settings 6.3
Same name and namespace in other branches
- 6.2 nodeformsettings.module \nodeformsettings_settings_submit()
- 7.3 nodeformsettings.module \nodeformsettings_settings_submit()
- 7.2 nodeformsettings.module \nodeformsettings_settings_submit()
Submit callback for the node form alter
See also
1 string reference to 'nodeformsettings_settings_submit'
- nodeformsettings_form_alter in ./
nodeformsettings.module - Implementation of hook_form_alter()
File
- ./
nodeformsettings.module, line 157 - main file, only one hook_form_alter to change several settings
Code
function nodeformsettings_settings_submit($form, &$form_state) {
// Get the values sent from the form and save them in $values
$values = $form_state['values'];
// dprint_r($values);
// Save the value of $values['var'] in $name. This variable will
// be used to define the name in variable_set($name, $values)
// This will be something like nodeformsettings_contenttype
$name = 'nodeformsettings_' . $values['var'];
// Get the elements from the function and loop to get only the keys, not the values
$elements = nodeformsettings_elements_default();
foreach ($elements as $k => $v) {
// Build the $ignore array with only the keys ($k)
$ignore[] = $k;
}
// Add to the $ignore array the $name
$ignore[] = $name;
// Loop thought the array of $values to unset everything but our values in $ignore
foreach ($values as $key => $value) {
// if the key IS NOT in the $ignore array, then unset that value
if (!in_array($key, $ignore)) {
unset($values[$key]);
}
else {
// Build the $data array wich we will send to the variable_set function
$data[$key] = $value;
}
}
variable_set($name, $data);
// Purge all variables created by hook_node_type
nodeformsettings_purge($form_state['values']['var']);
}