You are here

public function WebformSubmissionLimitBlock::blockValidate in Webform 6.x

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

Overrides BlockPluginTrait::blockValidate

File

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

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));
    }
  }
}