public function PluginConditionSettingsForm::buildForm in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Form/PluginConditionSettingsForm.php \Drupal\rng\Form\PluginConditionSettingsForm::buildForm()
- 3.x src/Form/PluginConditionSettingsForm.php \Drupal\rng\Form\PluginConditionSettingsForm::buildForm()
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/ PluginConditionSettingsForm.php, line 54
Class
- PluginConditionSettingsForm
- Configure condition plugin settings.
Namespace
Drupal\rng\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$all_roles = Role::loadMultiple();
unset($all_roles[AccountInterface::ANONYMOUS_ROLE]);
unset($all_roles[AccountInterface::AUTHENTICATED_ROLE]);
$roles = [];
$values = [];
foreach ($all_roles as $role) {
/** @var \Drupal\user\RoleInterface $role */
$roles[$role
->id()] = $role
->label();
if ($role
->getThirdPartySetting('rng', 'condition_rng_role', FALSE)) {
$values[] = $role
->id();
}
}
$form['roles'] = [
'#type' => 'checkboxes',
'#options' => $roles,
'#title' => $this
->t('Roles'),
'#description' => $this
->t('Expose these roles to condition plugin. If no roles are selected, all roles will be made available.'),
'#default_value' => $values,
];
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
'#button_type' => 'primary',
];
return $form;
}