You are here

public function RemoveRoleFromUserAction::validateForm in Business Rules 8

Same name and namespace in other branches
  1. 2.x modules/br_group/src/Plugin/BusinessRulesAction/RemoveRoleFromUserAction.php \Drupal\br_group\Plugin\BusinessRulesAction\RemoveRoleFromUserAction::validateForm()

Plugin form validator.

If the plugin needs to perform a form validation, override this function.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state object.

Overrides BusinessRulesItemPluginBase::validateForm

File

modules/br_group/src/Plugin/BusinessRulesAction/RemoveRoleFromUserAction.php, line 94

Class

RemoveRoleFromUserAction
Class RemoveRoleFromUserAction.

Namespace

Drupal\br_group\Plugin\BusinessRulesAction

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->getValue('user_key') == 'username' && $form_state
    ->getValue('user_name') == '') {
    $form_state
      ->setErrorByName('user_name', t('User name is required.'));
  }
  elseif ($form_state
    ->getValue('user_key') == 'userid' && $form_state
    ->getValue('user_id') == '') {
    $form_state
      ->setErrorByName('user_id', t('User id is required.'));
  }
}