function disable_field_disable_validate in Disable Field 8
Same name and namespace in other branches
- 7 disable_field.module \disable_field_disable_validate()
Implements validate function.
1 string reference to 'disable_field_disable_validate'
File
- ./
disable_field.module, line 111
Code
function disable_field_disable_validate(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$add_disable = $values['add_disable'];
$edit_disable = $values['edit_disable'];
// For add checkbox;
if ($add_disable == 'roles') {
if (empty($values['add_disable_roles'])) {
$form_state
->setErrorByName('roles_add', t('Please, choose at least one role.'));
}
}
// For Edit checkbox.
if ($edit_disable == 'roles') {
if (empty($values['edit_disable_roles'])) {
$form_state
->setErrorByName('roles_edit', t('Please, choose at least one role.'));
}
}
}