You are here

public function SidrTrigger::blockValidate in Sidr: Accessible Mobile Menus 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Block/SidrTrigger.php \Drupal\sidr\Plugin\Block\SidrTrigger::blockValidate()
  2. 8 src/Plugin/Block/SidrTrigger.php \Drupal\sidr\Plugin\Block\SidrTrigger::blockValidate()

Overrides BlockPluginTrait::blockValidate

File

src/Plugin/Block/SidrTrigger.php, line 235

Class

SidrTrigger
Provides a trigger button with Sidr integration.

Namespace

Drupal\sidr\Plugin\Block

Code

public function blockValidate($form, FormStateInterface $form_state) {
  parent::blockValidate($form, $form_state);
  $values = $form_state
    ->getValues();
  $values = $values['basic'] + $values['advanced'];

  // Either trigger text or trigger icon must be set.
  if (!$values['trigger_text'] && !$values['trigger_icon']) {
    $message = $this
      ->t('Please provide either trigger text or a trigger icon.');
    $form_state
      ->setError($form['basic']['trigger_text'], $message);
    $form_state
      ->setError($form['advanced']['trigger_icon'], $message);
  }
}