protected function EditFieldForm::buildEntity

Returns a cloned entity containing updated field values.

Calling code may then validate the returned entity, and if valid, transfer it back to the form state and save it.

2 calls to EditFieldForm::buildEntity()
EditFieldForm::submit in drupal/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php
Saves the entity with updated values for the edited field.
EditFieldForm::validate in drupal/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php
Validates the form.

File

drupal/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php, line 100
Contains \Drupal\edit\Form\EditFieldForm.

Class

EditFieldForm
Builds and process a form for editing a single entity field.

Namespace

Drupal\edit\Form

Code

protected function buildEntity(array $form, array &$form_state) {
  $entity = clone $form_state['entity'];
  field_attach_extract_form_values($entity, $form, $form_state, array(
    'field_name' => $form_state['field_name'],
  ));

  // @todo Refine automated log messages and abstract them to all entity
  //   types: http://drupal.org/node/1678002.
  if ($entity
    ->entityType() == 'node' && $entity
    ->isNewRevision() && !isset($entity->log)) {
    $instance = field_info_instance($entity
      ->entityType(), $form_state['field_name'], $entity
      ->bundle());
    $entity->log = t('Updated the %field-name field through in-place editing.', array(
      '%field-name' => $instance['label'],
    ));
  }
  return $entity;
}