public function EditableFieldsForm::submitForm in Editable Fields 8
Same name and namespace in other branches
- 1.0.x src/Form/EditableFieldsForm.php \Drupal\editablefields\Form\EditableFieldsForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ EditableFieldsForm.php, line 128
Class
- EditableFieldsForm
- Class EditableFieldsForm.
Namespace
Drupal\editablefields\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->setRebuild(TRUE);
$entity = $this->entity;
$field = $this->field_name;
$form_display = $this
->getFormDisplay();
if (!$form_display || !$form_display
->id()) {
return;
}
// Update the entity.
if ($component = $form_display
->getComponent($field)) {
$widget = $form_display
->getRenderer($field);
$items = $entity
->get($field);
$items
->filterEmptyItems();
$widget
->extractFormValues($items, $form, $form_state);
$entity
->save();
}
}