function ManageConditions::buildForm
Same name in other branches
- 8.x-3.x src/Form/ManageConditions.php \Drupal\ctools\Form\ManageConditions::buildForm()
Overrides FormInterface::buildForm
File
-
src/
Form/ ManageConditions.php, line 65
Class
Namespace
Drupal\ctools\FormCode
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 = [];
$contexts = $this->getContexts($cached_values);
foreach ($this->manager
->getDefinitionsForContexts($contexts) as $plugin_id => $definition) {
$options[$plugin_id] = (string) $definition['label'];
}
$form['items'] = [
'#type' => 'markup',
'#prefix' => '<div id="configured-conditions">',
'#suffix' => '</div>',
'#theme' => 'table',
'#header' => [
$this->t('Plugin Id'),
$this->t('Summary'),
$this->t('Operations'),
],
'#rows' => $this->renderRows($cached_values),
'#empty' => $this->t('No required conditions have been configured.'),
];
$form['conditions'] = [
'#type' => 'select',
'#options' => $options,
];
$form['add'] = [
'#type' => 'submit',
'#name' => 'add',
'#value' => $this->t('Add Condition'),
'#ajax' => [
'callback' => [
$this,
'add',
],
'event' => 'click',
],
'#submit' => [
'callback' => [
$this,
'submitForm',
],
],
];
return $form;
}