protected function ConditionalFieldsFormHelper::addValidationCallback in Conditional Fields 8
Same name and namespace in other branches
- 4.x src/ConditionalFieldsFormHelper.php \Drupal\conditional_fields\ConditionalFieldsFormHelper::addValidationCallback()
Add validation callback to manage dependent fields validation.
File
- src/
ConditionalFieldsFormHelper.php, line 160
Class
- ConditionalFieldsFormHelper
- Helper to interact with forms.
Namespace
Drupal\conditional_fieldsCode
protected function addValidationCallback() {
$this->form['#validate'][] = [
self::class,
'formValidate',
];
// Initialize validation information every time the form is rendered to avoid
// stale data after a failed submission.
$this->form_state
->setValue('conditional_fields_untriggered_dependents', []);
return $this;
}