public function RemoveUserRole::getSettingsForm in Business Rules 8
Same name and namespace in other branches
- 2.x src/Plugin/BusinessRulesAction/RemoveUserRole.php \Drupal\business_rules\Plugin\BusinessRulesAction\RemoveUserRole::getSettingsForm()
Return the form array.
@internal param array $form
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state object.
\Drupal\business_rules\ItemInterface $item: The configured item.
Return value
array The render array for the settings form.
Overrides BusinessRulesItemPluginBase::getSettingsForm
File
- src/
Plugin/ BusinessRulesAction/ RemoveUserRole.php, line 30
Class
- RemoveUserRole
- Class RemoveUserRole.
Namespace
Drupal\business_rules\Plugin\BusinessRulesActionCode
public function getSettingsForm(array &$form, FormStateInterface $form_state, ItemInterface $item) {
$settings['user_container'] = [
'#type' => 'select',
'#title' => t('User container'),
'#default_value' => $item
->getSettings('user_container'),
'#options' => [
'current' => t('Current user'),
'by_id' => t('By user id'),
'variable' => t('User variable'),
],
];
$settings['uid'] = [
'#type' => 'textfield',
'#title' => t('User id'),
'#default_value' => $item
->getSettings('uid'),
'#description' => t('You can use variables here.'),
'#states' => [
'visible' => [
'select[name="user_container"]' => [
'value' => 'by_id',
],
],
],
];
$settings['variable'] = [
'#type' => 'select',
'#title' => t('User variable'),
'#default_option' => $item
->getSettings('variable'),
'#description' => t('The variable containing the user. Only variables type: "User variable".'),
'#options' => $this->util
->getVariablesOptions([
'user_variable',
]),
'#states' => [
'visible' => [
'select[name="user_container"]' => [
'value' => 'variable',
],
],
],
];
$settings['roles'] = [
'#type' => 'checkboxes',
'#title' => t('Roles'),
'#required' => TRUE,
'#options' => $this->util
->getUserRolesOptions(),
'#default_value' => is_array($item
->getSettings('roles')) ? $item
->getSettings('roles') : [],
'#description' => t('Roles to remove.'),
];
return $settings;
}