public function ManageConditions::buildForm in Chaos Tool Suite (ctools) 8.3
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 FormInterface::buildForm
File
- src/
Form/ ManageConditions.php, line 59
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;
}