You are here

public function DateRecurInterpreterEditForm::save in Recurring Dates Field 8.2

Same name and namespace in other branches
  1. 3.x src/Form/DateRecurInterpreterEditForm.php \Drupal\date_recur\Form\DateRecurInterpreterEditForm::save()
  2. 3.0.x src/Form/DateRecurInterpreterEditForm.php \Drupal\date_recur\Form\DateRecurInterpreterEditForm::save()
  3. 3.1.x src/Form/DateRecurInterpreterEditForm.php \Drupal\date_recur\Form\DateRecurInterpreterEditForm::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/DateRecurInterpreterEditForm.php, line 105

Class

DateRecurInterpreterEditForm
Edit form for date recur interpreter entities.

Namespace

Drupal\date_recur\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  $entity = $this
    ->getEntity();
  $key = 'configure';
  $plugin = $entity
    ->getPlugin();
  if ($plugin
    ->hasFormClass($key)) {
    $subformState = SubformState::createForSubform($form['configure'], $form, $form_state);
    $this->pluginFormFactory
      ->createInstance($plugin, $key)
      ->submitConfigurationForm($form['configure'], $subformState);
  }
  $result = $entity
    ->save();
  $this
    ->messenger()
    ->addStatus($this
    ->t('Saved the %label interpreter.', [
    '%label' => $entity
      ->label(),
  ]));
  $form_state
    ->setRedirectUrl($entity
    ->toUrl('collection'));
  return $result;
}