public function QueuerAddForm::buildForm in Purge 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 ConfigFormBase::buildForm
File
- modules/
purge_ui/ src/ Form/ QueuerAddForm.php, line 59
Class
- QueuerAddForm
- Add a queuer.
Namespace
Drupal\purge_ui\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$definitions = $this->purgeQueuers
->getPlugins();
$form = parent::buildForm($form, $form_state);
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
// List all available queuers.
$options = [];
foreach ($this->purgeQueuers
->getPluginsAvailable() as $plugin_id) {
$options[$plugin_id] = $this
->t("@label: @description", [
'@label' => $definitions[$plugin_id]['label'],
'@description' => $definitions[$plugin_id]['description'],
]);
}
$form['id'] = [
'#default_value' => count($options) ? key($options) : NULL,
'#type' => 'radios',
'#options' => $options,
];
// Update the buttons and bind callbacks.
$form['actions']['submit'] = [
'#access' => count($options),
'#type' => 'submit',
'#button_type' => 'primary',
'#value' => $this
->t("Add"),
'#ajax' => [
'callback' => '::addQueuer',
],
];
$form['actions']['cancel'] = [
'#type' => 'submit',
'#value' => $this
->t('Cancel'),
'#weight' => -10,
'#ajax' => [
'callback' => '::closeDialog',
],
];
return $form;
}