public function WidgetBase::validate in Entity Browser 8
Same name and namespace in other branches
- 8.2 src/WidgetBase.php \Drupal\entity_browser\WidgetBase::validate()
Validates form.
Parameters
array $form: Form.
\Drupal\Core\Form\FormStateInterface $form_state: Form state object.
Overrides WidgetInterface::validate
1 call to WidgetBase::validate()
- View::validate in src/
Plugin/ EntityBrowser/ Widget/ View.php - Validates form.
1 method overrides WidgetBase::validate()
- View::validate in src/
Plugin/ EntityBrowser/ Widget/ View.php - Validates form.
File
- src/
WidgetBase.php, line 291
Class
- WidgetBase
- Base class for widget plugins.
Namespace
Drupal\entity_browserCode
public function validate(array &$form, FormStateInterface $form_state) {
$entities = $this
->prepareEntities($form, $form_state);
$validators = $form_state
->get([
'entity_browser',
'validators',
]);
if ($validators) {
$violations = $this
->runWidgetValidators($entities, $validators);
foreach ($violations as $violation) {
$form_state
->setError($form['widget'], $violation
->getMessage());
}
}
}