public function OembedProviderBucketForm::save in oEmbed Providers 2.x
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/
OembedProviderBucketForm.php, line 139
Class
- OembedProviderBucketForm
- Form controller for the oEmbed provider bucket edit/add forms.
Namespace
Drupal\oembed_providersCode
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$providers = Checkboxes::getCheckedCheckboxes($entity
->get('providers'));
$entity
->set('providers', $providers);
$status = $entity
->save();
if ($status === SAVED_NEW) {
$this
->messenger()
->addMessage($this
->t('The %label oEmbed provider bucket was created.', [
'%label' => $entity
->label(),
]));
}
else {
$this
->messenger()
->addMessage($this
->t('The %label oEmbed provider bucket was updated.', [
'%label' => $entity
->label(),
]));
}
$form_state
->setRedirect('entity.oembed_provider_bucket.collection');
}