You are here

public function BusinessRuleForm::validateForm in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Form/BusinessRuleForm.php \Drupal\business_rules\Form\BusinessRuleForm::validateForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormBase::validateForm

File

src/Form/BusinessRuleForm.php, line 546

Class

BusinessRuleForm
Class BusinessRuleForm.

Namespace

Drupal\business_rules\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {

  // Validate de Business Rule Machine Name.
  $id = $form_state
    ->getValue('id');
  if ($id && $this->entity
    ->isNew()) {
    $br = BusinessRule::load($id);
    if (!empty($br)) {
      $form_state
        ->setErrorByName('id', $this
        ->t('The machine-readable name is already in use. It must be unique.'));
    }
  }
}