You are here

public function EmbedCode::validate in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/EntityBrowser/Widget/EmbedCode.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EmbedCode::validate()
  2. 8 src/Plugin/EntityBrowser/Widget/EmbedCode.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EmbedCode::validate()
  3. 8.2 src/Plugin/EntityBrowser/Widget/EmbedCode.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EmbedCode::validate()

Overrides EntityFormProxy::validate

File

src/Plugin/EntityBrowser/Widget/EmbedCode.php, line 55

Class

EmbedCode
An Entity Browser widget for creating media entities from embed codes.

Namespace

Drupal\lightning_media\Plugin\EntityBrowser\Widget

Code

public function validate(array &$form, FormStateInterface $form_state) {
  $value = $this
    ->getCurrentValue($form_state);
  if ($value) {
    parent::validate($form, $form_state);
  }
  elseif ($form_state
    ->isSubmitted()) {
    $form_state
      ->setError($form['widget']['input'], $this
      ->t('You must enter a URL or embed code.'));
  }
}