You are here

public function ReactionDeleteForm::buildForm in Context 8.0

Same name and namespace in other branches
  1. 8.4 modules/context_ui/src/Form/ReactionDeleteForm.php \Drupal\context_ui\Form\ReactionDeleteForm::buildForm()
  2. 8 modules/context_ui/src/Form/ReactionDeleteForm.php \Drupal\context_ui\Form\ReactionDeleteForm::buildForm()

Form constructor.

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

array The form structure.

Overrides ConfirmFormBase::buildForm

File

modules/context_ui/src/Form/ReactionDeleteForm.php, line 88

Class

ReactionDeleteForm

Namespace

Drupal\context_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, ContextInterface $context = NULL, $reaction_id = NULL) {
  $this->context = $context;
  $this->reaction = $this->context
    ->getReaction($reaction_id);
  $form = parent::buildForm($form, $form_state);

  // Remove the cancel button if this is an AJAX request since Drupals built
  // in modal dialogues does not handle buttons that are not a primary
  // button very well.
  if ($this
    ->getRequest()
    ->isXmlHttpRequest()) {
    unset($form['actions']['cancel']);
  }
  $form['actions']['submit']['#ajax'] = [
    'callback' => '::submitFormAjax',
  ];
  return $form;
}