You are here

public function WebformSubmissionLimitBlock::blockValidate in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/Block/WebformSubmissionLimitBlock.php \Drupal\webform\Plugin\Block\WebformSubmissionLimitBlock::blockValidate()

Overrides BlockPluginTrait::blockValidate

File

src/Plugin/Block/WebformSubmissionLimitBlock.php, line 261

Class

WebformSubmissionLimitBlock
Provides a 'Webform submission limit' block.

Namespace

Drupal\webform\Plugin\Block

Code

public function blockValidate($form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  if ($values['entity_type']) {
    $t_args = [
      '%label' => $form['advanced']['entity_id']['#title'],
    ];
    if (empty($values['entity_id'])) {
      $form_state
        ->setError($form['advanced']['entity_id'], $this
        ->t('An %label id is required.', $t_args));
    }
    elseif (!$this->entityTypeManager
      ->getStorage($values['entity_type'])
      ->load($values['entity_id'])) {
      $form_state
        ->setError($form['advanced']['entity_id'], $this
        ->t('A valid %label is required.', $t_args));
    }
  }
}