You are here

public function WebformOptionsCustomForm::save in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_options_custom/src/WebformOptionsCustomForm.php \Drupal\webform_options_custom\WebformOptionsCustomForm::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/webform_options_custom/src/WebformOptionsCustomForm.php, line 439

Class

WebformOptionsCustomForm
Provides a form to set webform options custom.

Namespace

Drupal\webform_options_custom

Code

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

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