protected function QuickEditFieldForm::buildEntity in Drupal 8
Same name and namespace in other branches
- 9 core/modules/quickedit/src/Form/QuickEditFieldForm.php \Drupal\quickedit\Form\QuickEditFieldForm::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 QuickEditFieldForm::buildEntity()
- QuickEditFieldForm::submitForm in core/
modules/ quickedit/ src/ Form/ QuickEditFieldForm.php - Saves the entity with updated values for the edited field.
- QuickEditFieldForm::validateForm in core/
modules/ quickedit/ src/ Form/ QuickEditFieldForm.php - Form validation handler.
File
- core/
modules/ quickedit/ src/ Form/ QuickEditFieldForm.php, line 170
Class
- QuickEditFieldForm
- Builds and process a form for editing a single entity field.
Namespace
Drupal\quickedit\FormCode
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.', [
'%field-name' => $entity
->get($field_name)
->getFieldDefinition()
->getLabel(),
]);
}
return $entity;
}