Example #1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $cached_values = $form_state->getTemporaryValue('wizard');
     $this->machine_name = $cached_values['id'];
     $form['#attached']['library'][] = 'core/drupal.dialog.ajax';
     $options = [];
     foreach ($this->typedDataManager->getDefinitions() as $plugin_id => $definition) {
         $options[$plugin_id] = (string) $definition['label'];
     }
     $form['items'] = array('#type' => 'markup', '#prefix' => '<div id="configured-contexts">', '#suffix' => '</div>', '#theme' => 'table', '#header' => array($this->t('Information'), $this->t('Description'), $this->t('Operations')), '#rows' => $this->renderContexts($cached_values), '#empty' => t('No required contexts have been configured.'));
     $form['contexts'] = ['#type' => 'select', '#options' => $options];
     $form['add'] = ['#type' => 'submit', '#name' => 'add', '#value' => t('Add required context'), '#ajax' => ['callback' => [$this, 'add'], 'event' => 'click'], '#submit' => ['callback' => [$this, 'submitform']]];
     return $form;
 }