public function BlockFieldTestValidationBlock::blockValidate in Block field 8
Overrides BlockPluginTrait::blockValidate
File
- tests/
modules/ block_field_test/ src/ Plugin/ Block/ BlockFieldTestValidationBlock.php, line 50
Class
- BlockFieldTestValidationBlock
- Provides a 'Block field test validation' block.
Namespace
Drupal\block_field_test\Plugin\BlockCode
public function blockValidate($form, FormStateInterface $form_state) {
if ($form_state
->getValue('content') == 'error by name') {
$form_state
->setErrorByName('content', 'Come ere boi!');
}
if ($form_state
->getValue('content') == 'error by element') {
$form_state
->setError($form['content'], 'Gimmie them toez!');
}
}