getConfirmText example

/** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state) {
    // Get the current major version.     [$this->destinationSiteVersion] = explode('.', \Drupal::VERSION, 2);
    $form = [];
    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->getConfirmText(),
      '#button_type' => 'primary',
      '#weight' => 10,
    ];
    return $form;
  }

  /** * Helper to redirect to the Overview form. * * @return \Symfony\Component\HttpFoundation\RedirectResponse * A redirect response object that may be returned by the controller. * * @throws \Drupal\Core\TempStore\TempStoreException * Thrown when a lock for the backend storage could not be acquired. */
// Do not attach fields to the confirm form.     return $form;
  }

  /** * {@inheritdoc} */
  protected function actions(array $form, FormStateInterface $form_state) {
    return [
      'submit' => [
        '#type' => 'submit',
        '#value' => $this->getConfirmText(),
        '#submit' => [
          [$this, 'submitForm'],
        ],
      ],
      'cancel' => ConfirmFormHelper::buildCancelLink($this$this->getRequest()),
    ];
  }

  /** * {@inheritdoc} * * The save() method is not used in ContentEntityConfirmFormBase. This * overrides the default implementation that saves the entity. * * Confirmation forms should override submitForm() instead for their logic. */

  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['#title'] = $this->getQuestion();

    $form['#attributes']['class'][] = 'confirmation';
    $form['description'] = ['#markup' => $this->getDescription()];
    $form[$this->getFormName()] = ['#type' => 'hidden', '#value' => 1];

    $form['actions'] = ['#type' => 'actions'];
    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->getConfirmText(),
      '#button_type' => 'primary',
    ];

    $form['actions']['cancel'] = ConfirmFormHelper::buildCancelLink($this$this->getRequest());

    // By default, render the form using theme_confirm_form().     if (!isset($form['#theme'])) {
      $form['#theme'] = 'confirm_form';
    }
    return $form;
  }

}

    return $form;
  }

  /** * {@inheritdoc} */
  protected function actions(array $form, FormStateInterface $form_state) {
    return [
      'submit' => [
        '#type' => 'submit',
        '#value' => $this->getConfirmText(),
        '#submit' => [
          [$this, 'submitForm'],
        ],
      ],
      'cancel' => ConfirmFormHelper::buildCancelLink($this$this->getRequest()),
    ];
  }

  /** * {@inheritdoc} * * The save() method is not used in EntityConfirmFormBase. This overrides the * default implementation that saves the entity. * * Confirmation forms should override submitForm() instead for their logic. */
Home | Imprint | This part of the site doesn't use cookies.