You are here

public function ContextEditForm::form in Context 8.0

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

Gets the actual form array to be built.

Overrides ContextFormBase::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

modules/context_ui/src/Form/ContextEditForm.php, line 18

Class

ContextEditForm

Namespace

Drupal\context_ui\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  // Store contexts on the form state so that plugins can use these values
  // when building their forms.
  $form_state
    ->setTemporaryValue('gathered_contexts', $this->contextRepository
    ->getAvailableContexts());
  $form['require_all_conditions'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Require all conditions'),
    '#description' => $this
      ->t('If checked, all conditions must be met for this context to be active. Otherwise, the first condition that is met will activate this context.'),
    '#default_value' => $this->entity
      ->requiresAllConditions(),
  ];
  $form['conditions'] = [
    '#prefix' => '<div id="context-conditions">',
    '#suffix' => '</div>',
    '#markup' => '<h3>' . $this
      ->t('Conditions') . '</h3>',
    '#tree' => TRUE,
    '#process' => array(
      array(
        $this,
        'processConditions',
      ),
    ),
  ];
  $form['reactions'] = [
    '#prefix' => '<div id="context-reactions">',
    '#suffix' => '</div>',
    '#markup' => '<h3>' . $this
      ->t('Reactions') . '</h3>',
    '#tree' => TRUE,
    '#process' => array(
      array(
        $this,
        'processReactions',
      ),
    ),
  ];
  return $form;
}