public function ConditionalFieldsFormHelper::addValidationCallback in Conditional Fields 4.x
Same name and namespace in other branches
- 8 src/ConditionalFieldsFormHelper.php \Drupal\conditional_fields\ConditionalFieldsFormHelper::addValidationCallback()
Add validation callback to manage dependent fields validation.
File
- src/
ConditionalFieldsFormHelper.php, line 206
Class
- ConditionalFieldsFormHelper
- Helper to interact with forms.
Namespace
Drupal\conditional_fieldsCode
public 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;
}