You are here

public function UserVariable::getSettingsForm in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/BusinessRulesVariable/UserVariable.php \Drupal\business_rules\Plugin\BusinessRulesVariable\UserVariable::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/BusinessRulesVariable/UserVariable.php, line 35

Class

UserVariable
A variable representing one user account.

Namespace

Drupal\business_rules\Plugin\BusinessRulesVariable

Code

public function getSettingsForm(array &$form, FormStateInterface $form_state, ItemInterface $item) {
  $settings['current_or_defined'] = [
    '#type' => 'select',
    '#title' => t('Current user or defined user?'),
    '#description' => t('Current user or load user by user id.'),
    '#required' => TRUE,
    '#options' => [
      'current' => t('Current'),
      'defined' => t('Defined'),
    ],
    '#default_value' => $item
      ->getSettings('current_or_defined'),
  ];
  $settings['user_id'] = [
    '#type' => 'textfield',
    '#title' => t('User id. You may use a variable to set this value.'),
    '#description' => t('The numeric value for the user id.'),
    '#default_value' => $item
      ->getSettings('user_id'),
    '#states' => [
      'visible' => [
        'select[name="current_or_defined"]' => [
          'value' => 'defined',
        ],
      ],
    ],
  ];
  return $settings;
}