You are here

public function WebformOptionsForm::save in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformOptionsForm.php \Drupal\webform\WebformOptionsForm::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/WebformOptionsForm.php, line 262

Class

WebformOptionsForm
Provides a form to set options.

Namespace

Drupal\webform

Code

public function save(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\webform\WebformOptionsInterface $webform_options */
  $webform_options = $this
    ->getEntity();
  $webform_options
    ->save();
  $context = [
    '@label' => $webform_options
      ->label(),
    'link' => $webform_options
      ->toLink($this
      ->t('Edit'), 'edit-form')
      ->toString(),
  ];
  $this
    ->logger('webform')
    ->notice('Options @label saved.', $context);
  $this
    ->messenger()
    ->addStatus($this
    ->t('Options %label saved.', [
    '%label' => $webform_options
      ->label(),
  ]));
  $form_state
    ->setRedirect('entity.webform_options.collection');
}