public function ResponseHeaderForm::save in HTTP Response Headers 8.2
Same name and namespace in other branches
- 2.0.x src/Form/ResponseHeaderForm.php \Drupal\http_response_headers\Form\ResponseHeaderForm::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
- src/
Form/ ResponseHeaderForm.php, line 97
Class
- ResponseHeaderForm
- Form handler for the Response Header add and edit forms.
Namespace
Drupal\http_response_headers\FormCode
public function save(array $form, FormStateInterface $form_state) {
$response_header = $this->entity;
$status = $response_header
->save();
if ($status) {
$this
->messenger()
->addMessage($this
->t('Saved the %label Response Header.', array(
'%label' => $response_header
->label(),
)));
}
else {
$this
->messenger()
->addMessage($this
->t('The %label Response Header was not saved.', array(
'%label' => $response_header
->label(),
)));
}
$form_state
->setRedirect('entity.response_header.collection');
}