function _skills_term_validation in Opigno module 3.x
Same name and namespace in other branches
- 8 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 667 - 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));
}
}