['#type' => 'textfield']] + $form; } /** * {@inheritdoc} */ public function blockValidate($form, FormStateInterface $form_state) { if (!ctype_digit($form_state->getValue('digits'))) { $form_state->setErrorByName('digits', $this->t('Only digits are allowed')); } } /** * {@inheritdoc} */ public function build() { return ['#markup' => 'foo']; } }