Commit cd156aa2 authored by Wolfgang Ziegler's avatar Wolfgang Ziegler
Browse files

Issue #2672456 by fago: Add cancel button to embed form example.

parent a190a108
Loading
Loading
Loading
Loading
+1 −0
Changes for src/Form/ReactionRuleEditForm.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ class ReactionRuleEditForm extends RulesComponentFormBase {
    $actions['submit']['#value'] = $this->t('Save');
    $actions['cancel'] = [
      '#type' => 'submit',
      '#limit_validation_errors' => [['locked']],
      '#value' => $this->t('Cancel'),
      '#submit' => ['::cancel'],
    ];
+1 −1
Changes for src/Form/TempStoreTrait.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -238,7 +238,7 @@ trait TempStoreTrait {
   */
  public function validateLock(array &$form, FormStateInterface $form_state) {
    if ($this->isLocked()) {
      $form_state->setError($form, $this->lockInformationMessage());
      $form_state->setErrorByName('locked', $this->lockInformationMessage());
    }
  }

+16 −0
Changes for tests/modules/rules_test_ui_embed/src/Form/SettingsForm.php: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -68,6 +68,13 @@ class SettingsForm extends ConfigFormBase {
    $form['conditions'] = $this->rulesUiHandler->getForm()
      ->buildForm([], $form_state);

    $form['actions']['cancel'] = [
      '#type' => 'submit',
      '#limit_validation_errors' => [['locked']],
      '#value' => $this->t('Cancel'),
      '#submit' => ['::cancel'],
    ];

    return $form;
  }

@@ -97,4 +104,13 @@ class SettingsForm extends ConfigFormBase {
    parent::submitForm($form, $form_state);
  }

  /**
   * Form submission handler for the 'cancel' action.
   */
  public function cancel(array $form, FormStateInterface $form_state) {
    $this->rulesUiHandler->clearTemporaryStorage();
    drupal_set_message($this->t('Canceled.'));
    $form_state->setRedirectUrl($this->rulesUiHandler->getBaseRouteUrl());
  }

}
+1 −1

File changed.

Contains only whitespace changes.