You are here

public function IFrame::validateConfigurationForm in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/EntityBrowser/Display/IFrame.php \Drupal\entity_browser\Plugin\EntityBrowser\Display\IFrame::validateConfigurationForm()

Implements PluginFormInterface::validateConfigurationForm().

Overrides PluginConfigurationFormTrait::validateConfigurationForm

1 method overrides IFrame::validateConfigurationForm()
Modal::validateConfigurationForm in src/Plugin/EntityBrowser/Display/Modal.php
Implements PluginFormInterface::validateConfigurationForm().

File

src/Plugin/EntityBrowser/Display/IFrame.php, line 275

Class

IFrame
Presents entity browser in an iFrame.

Namespace

Drupal\entity_browser\Plugin\EntityBrowser\Display

Code

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

  // We want all positive integers, or percentages between 1% and 100%.
  $pattern = '/^([1-9][0-9]*|([2-9][0-9]{0,1}%)|(1[0-9]{0,2}%))$/';
  if (preg_match($pattern, $form_state
    ->getValue('width')) == 0) {
    $form_state
      ->setError($form['width'], $this
      ->t('Width must be a number greater than 0, or a percentage between 1% and 100%.'));
  }
  if ($form_state
    ->getValue('height') <= 0) {
    $form_state
      ->setError($form['height'], $this
      ->t('Height must be greater than 0.'));
  }
}