protected QuickEditFieldForm::init(FormStateInterface $form_state, EntityInterface $entity, $field_name)
Initialize the form state and the entity before the first form build.
File
- core/modules/quickedit/src/Form/QuickEditFieldForm.php, line 126
Class
- QuickEditFieldForm
- Builds and process a form for editing a single entity field.
Namespace
Drupal\quickedit\Form
Code
protected function init(FormStateInterface $form_state, EntityInterface $entity, $field_name) { // @todo Rather than special-casing $node->revision, invoke prepareEdit() // once https://www.drupal.org/node/1863258 lands. if ($entity->getEntityTypeId() == 'node') { $node_type = $this->nodeTypeStorage->load($entity->bundle()); $entity->setNewRevision($node_type->isNewRevision()); $entity->revision_log = NULL; } $form_state->set('entity', $entity); $form_state->set('field_name', $field_name); // Fetch the display used by the form. It is the display for the 'default' // form mode, with only the current field visible. $display = EntityFormDisplay::collectRenderDisplay($entity, 'default'); foreach ($display->getComponents() as $name => $options) { if ($name != $field_name) { $display->removeComponent($name); } } $form_state->set('form_display', $display); }
Please login to continue.