function sweaver_type_form_submit in Sweaver 7
Same name and namespace in other branches
- 6 plugins/sweaver_plugin_editor/sweaver_plugin_editor.admin.inc \sweaver_type_form_submit()
Property new/edit submit callback.
1 string reference to 'sweaver_type_form_submit'
- sweaver_type_form in plugins/
sweaver_plugin_editor/ sweaver_plugin_editor.admin.inc - Type new/edit form.
File
- plugins/
sweaver_plugin_editor/ sweaver_plugin_editor.admin.inc, line 732 - Administrative functions for Sweaver.
Code
function sweaver_type_form_submit(&$form, &$form_state) {
$values = $form_state['values'];
// Build selector.
$type = new stdClass();
$type->oid = $values['oid'];
$type->name = $values['name'];
$type->description = $values['description'];
$options = $values['type_options'];
foreach ($options as $key => $value) {
if ($key !== $value) {
unset($options[$key]);
}
}
$type->type_options = serialize($options);
// Save property.
$update = isset($type->oid) && is_numeric($type->oid) ? array(
'oid',
) : array();
drupal_write_record('sweaver_type', $type, $update);
cache_clear_all('sweaver', 'cache');
// Message.
$action = empty($update) ? 'added' : 'updated';
$message = t('Type %type has been @action.', array(
'%type' => $type->name,
'@action' => $action,
));
// Message and redirect.
drupal_set_message($message);
$form_state['redirect'] = 'admin/config/user-interface/sweaver/editor/types';
}