public function MicrositeMenuItemForm::save in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 modules/entity_hierarchy_microsite/src/Form/MicrositeMenuItemForm.php \Drupal\entity_hierarchy_microsite\Form\MicrositeMenuItemForm::save()
Form submission handler for the 'save' action.
Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Overrides EntityForm::save
File
- modules/
entity_hierarchy_microsite/ src/ Form/ MicrositeMenuItemForm.php, line 122
Class
- MicrositeMenuItemForm
- Defines a class for menu link for microsite items.
Namespace
Drupal\entity_hierarchy_microsite\FormCode
public function save(array $form, FormStateInterface $form_state) {
// The entity is rebuilt in parent::submit().
$override = $this->entity;
$override
->save();
$this
->messenger()
->addStatus($this
->t('The override has been saved.'));
$form_state
->setRedirectUrl(new Url('entity.menu.edit_form', [
'menu' => 'entity-hierarchy-microsite',
]));
}