QuickEditFieldForm::buildEntity

protected QuickEditFieldForm::buildEntity(array $form, FormStateInterface $form_state)

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.

File

core/modules/quickedit/src/Form/QuickEditFieldForm.php, line 176

Class

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

Namespace

Drupal\quickedit\Form

Code

protected function buildEntity(array $form, FormStateInterface $form_state) {
  /** @var $entity \Drupal\Core\Entity\EntityInterface */
  $entity = clone $form_state->get('entity');
  $field_name = $form_state->get('field_name');

  $form_state->get('form_display')->extractFormValues($entity, $form, $form_state);

  // @todo Refine automated log messages and abstract them to all entity
  //   types: https://www.drupal.org/node/1678002.
  if ($entity->getEntityTypeId() == 'node' && $entity->isNewRevision() && $entity->revision_log->isEmpty()) {
    $entity->revision_log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel()));
  }

  return $entity;
}
doc_Drupal
2016-10-29 09:36:12
Comments
Leave a Comment

Please login to continue.