You are here

public function ReactionRuleEditForm::save in Rules 8.3

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/ReactionRuleEditForm.php, line 146

Class

ReactionRuleEditForm
Provides a form to edit a reaction rule.

Namespace

Drupal\rules\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  $this->rulesUiHandler
    ->getForm()
    ->submitForm($form, $form_state);
  $component = $this->rulesUiHandler
    ->getComponent();
  $this->entity
    ->updateFromComponent($component);

  // Persist changes by saving the entity.
  parent::save($form, $form_state);

  // Remove the temporarily stored component; it has been persisted now.
  $this->rulesUiHandler
    ->clearTemporaryStorage();
  $this
    ->messenger()
    ->addMessage($this
    ->t('Reaction rule %label has been updated.', [
    '%label' => $this->entity
      ->label(),
  ]));
}