You are here

function editablefields_form_submit in Editable Fields 7

Form submit callback: save the field modifications.

1 string reference to 'editablefields_form_submit'
editablefields_form in ./editablefields.module
Form builder callback.

File

./editablefields.module, line 536
Editable fields module.

Code

function editablefields_form_submit(&$form, &$form_state) {

  // Return the proper part of the form.
  $parents = $form_state['triggering_element']['#array_parents'];

  // Remove the 'actions' and 'link' elements.
  array_pop($parents);
  array_pop($parents);
  $element =& $form;
  foreach ($parents as $parent) {
    $element =& $element[$parent];
  }
  _editablefields_set_edit_mode($form_state, FALSE, $parents);

  // Re-load the entity so that changes from multiple editable fields will be
  // saved correctly.
  $entity_type = $element['#entity_type'];
  $entity_id = $element['#entity_id'];
  $entity = entity_load_single($entity_type, $entity_id);

  // Populate default node settings, e.g. revision.
  if ($entity_type == 'node') {
    node_object_prepare($entity);
  }
  entity_form_submit_build_entity($entity_type, $entity, $element, $form_state);
  entity_save($entity_type, $entity);
  $form_state['rebuild'] = TRUE;

  // Put back the updated entity for used during form rebuild.
  $form_state['editablefields_entities'][$entity_type][$entity_id] = $entity;
}