You are here

public function GroupHasUserCondition::validateForm in Business Rules 2.x

Same name and namespace in other branches
  1. 8 modules/br_group/src/Plugin/BusinessRulesCondition/GroupHasUserCondition.php \Drupal\br_group\Plugin\BusinessRulesCondition\GroupHasUserCondition::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/BusinessRulesCondition/GroupHasUserCondition.php, line 85

Class

GroupHasUserCondition
Class GroupHasUserCondition.

Namespace

Drupal\br_group\Plugin\BusinessRulesCondition

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.'));
  }
}