public static function VideoEmbedWidget::validateFormElement in Video 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldWidget/VideoEmbedWidget.php \Drupal\video\Plugin\Field\FieldWidget\VideoEmbedWidget::validateFormElement()
Form element validation handler for URL alias form element.
Parameters
array $element: The form element.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
File
- src/
Plugin/ Field/ FieldWidget/ VideoEmbedWidget.php, line 344
Class
- VideoEmbedWidget
- Plugin implementation of the 'video_embed' widget.
Namespace
Drupal\video\Plugin\Field\FieldWidgetCode
public static function validateFormElement(array &$element, FormStateInterface $form_state) {
$value = $element['#value'];
if (empty($value)) {
return;
}
$provider_manager = \Drupal::service('video.provider_manager');
$enabled_providers = $provider_manager
->loadDefinitionsFromOptionList($element['#allowed_providers']);
if (!$provider_manager
->loadApplicableDefinitionMatches($enabled_providers, $value)) {
$form_state
->setError($element, t('Could not find a video provider to handle the given URL.'));
}
}