You are here

function _skills_term_validation in Opigno module 8

Same name and namespace in other branches
  1. 3.x opigno_module.module \_skills_term_validation()

Custom validation on creating new skill term.

1 string reference to '_skills_term_validation'
opigno_module_form_alter in ./opigno_module.module
Implements hook_form_alter().

File

./opigno_module.module, line 668
Contains opigno_module.module.

Code

function _skills_term_validation(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $values['parent'] = [
    $values['parent'] => $values['parent'],
  ];
  $form_state
    ->setValues($values);
  if (isset($values['parent'][0]) && (isset($values['target_skill']) && $values['target_skill'] == 0)) {
    $message = 'Please select parent tree or parent skill other than <root>, or check the option ‘This is target skill’ if you want to create a new skill tree.';
    $form_state
      ->setErrorByName('parent', t($message));
  }
}