You are here

public function FacebookAlbumBlock::blockValidate in Facebook Album 8

Parameters

array $form:

\Drupal\Core\Form\FormStateInterface $form_state:

Overrides BlockPluginTrait::blockValidate

File

src/Plugin/Block/FacebookAlbumBlock.php, line 115
Contains \Drupal\facebook_album\Plugin\Block\FacebookAlbumBlock.

Class

FacebookAlbumBlock
Defines a facebook album block block type.

Namespace

Drupal\facebook_album\Plugin\Block

Code

public function blockValidate($form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();

  // Ensure numeric, non-zero values
  foreach ($values['display'] as $display_key => $display_values) {
    if (strpos($display_key, '_width') !== FALSE || strpos($display_key, '_height') !== FALSE) {
      if (!is_numeric($display_values) || $display_values <= 0) {
        $form_state
          ->setErrorByName('display][' . $display_key, $this
          ->t("Invalid value"));
      }
    }
  }
  parent::blockValidate($form, $form_state);
}