You are here

public function EntityInlineEntityFormController::entityFormSubmit in Inline Entity Form 7

Handles the submission of an entity form.

Prepares the entity stored in $entity_form['#entity'] for saving by copying the values from the form to matching properties and, if the entity is fieldable, invoking Field API submit.

Parameters

$entity_form: The entity form.

$form_state: The form state of the parent form.

3 calls to EntityInlineEntityFormController::entityFormSubmit()
CommerceProductInlineEntityFormController::entityFormSubmit in includes/commerce_product.inline_entity_form.inc
Overrides EntityInlineEntityFormController::entityFormSubmit().
NodeInlineEntityFormController::entityFormSubmit in includes/node.inline_entity_form.inc
Overrides EntityInlineEntityFormController::entityFormSubmit().
TaxonomyTermInlineEntityFormController::entityFormSubmit in includes/taxonomy_term.inline_entity_form.inc
Overrides EntityInlineEntityFormController::entityFormSubmit().
4 methods override EntityInlineEntityFormController::entityFormSubmit()
CommerceLineItemInlineEntityFormController::entityFormSubmit in includes/commerce_line_item.inline_entity_form.inc
Overrides EntityInlineEntityFormController::entityFormSubmit().
CommerceProductInlineEntityFormController::entityFormSubmit in includes/commerce_product.inline_entity_form.inc
Overrides EntityInlineEntityFormController::entityFormSubmit().
NodeInlineEntityFormController::entityFormSubmit in includes/node.inline_entity_form.inc
Overrides EntityInlineEntityFormController::entityFormSubmit().
TaxonomyTermInlineEntityFormController::entityFormSubmit in includes/taxonomy_term.inline_entity_form.inc
Overrides EntityInlineEntityFormController::entityFormSubmit().

File

includes/entity.inline_entity_form.inc, line 307
Defines the base inline entity form controller.

Class

EntityInlineEntityFormController
@file Defines the base inline entity form controller.

Code

public function entityFormSubmit(&$entity_form, &$form_state) {
  $info = entity_get_info($this->entityType);
  list(, , $bundle) = entity_extract_ids($this->entityType, $entity_form['#entity']);
  $entity = $entity_form['#entity'];
  $entity_values = drupal_array_get_nested_value($form_state['values'], $entity_form['#parents']);

  // Copy top-level form values that are not for fields to entity properties,
  // without changing existing entity properties that are not being edited by
  // this form. Copying field values must be done using field_attach_submit().
  $values_excluding_fields = $info['fieldable'] ? array_diff_key($entity_values, field_info_instances($this->entityType, $bundle)) : $entity_values;
  foreach ($values_excluding_fields as $key => $value) {
    $entity->{$key} = $value;
  }
  if ($info['fieldable']) {
    field_attach_submit($this->entityType, $entity, $entity_form, $form_state);
  }
}