You are here

public function BaseSettingsForm::validateAdEmbedCode in Facebook Instant Articles 3.x

Same name and namespace in other branches
  1. 8.2 src/Form/BaseSettingsForm.php \Drupal\fb_instant_articles\Form\BaseSettingsForm::validateAdEmbedCode()

Validate the Ad Embed code.

Parameters

array $form: FAPI array.

\Drupal\Core\Form\FormStateInterface $form_state: Form state.

File

src/Form/BaseSettingsForm.php, line 241

Class

BaseSettingsForm
Facebook Instant Articles base settings form.

Namespace

Drupal\fb_instant_articles\Form

Code

public function validateAdEmbedCode(array &$form, FormStateInterface $form_state) {

  // Only validate if Embed Code is selected as ad type.
  if ($form_state
    ->getValue('ads_type') != AdTypes::AD_TYPE_EMBED_CODE) {
    return;
  }
  $ads_embed_code = $form_state
    ->getValue('ads_embed_code');
  if (empty($ads_embed_code)) {
    $form_state
      ->setErrorByName('ads_embed_code', $this
      ->t('You must specify Embed Code for your Ads when using the Embed Code ad type.'));
  }
}