function _jeditable_save_other_field in jEditable inline content editing 6
Same name and namespace in other branches
- 6.2 jeditable.module \_jeditable_save_other_field()
Helper function to save other fields
1 call to _jeditable_save_other_field()
- _jeditable_ajax_save in ./
jeditable.module - Helper function to save a value using the jeditable callback
File
- ./
jeditable.module, line 379 - jeditable.module
Code
function _jeditable_save_other_field($node, $field, $value) {
module_load_include('inc', 'node', 'node.pages');
$field_name = $field['field_name'];
switch ($field['widget']['type']) {
case 'optionwidgets_buttons':
case 'optionwidgets_select':
$defaults = array_values(optionwidgets_options($field));
$value = $defaults[$value];
break;
}
$form_state = array();
$form_state['values'][$field_name][0]['value'] = $value;
$form_state['values']['op'] = t('Save');
$form_id = $node->type . '_node_form';
drupal_execute($form_id, &$form_state, (object) $node);
drupal_get_messages('status');
// Discard status messages
// @TODO: Do some Ajax with the warning and error messages.
//$messages = drupal_get_messages();
// Reload the node to get the value that was saved, if any. Avoid the cache.
$node = node_load(array(
"nid" => $node->nid,
));
if (isset($node->{$field_name})) {
$value = $node->{$field_name}[0]['value'];
$value = content_format($field_name, array(
'value' => $value,
));
}
else {
$value = NULL;
}
// Any HTML tags will already be in place outside the editor
$value = strip_tags($value);
return $value;
}