ValidationErrorBlock.php

Same filename in other branches
  1. 9 core/modules/settings_tray/tests/modules/settings_tray_test/src/Plugin/Block/ValidationErrorBlock.php
  2. 8.9.x core/modules/settings_tray/tests/modules/settings_tray_test/src/Plugin/Block/ValidationErrorBlock.php
  3. 11.x core/modules/settings_tray/tests/modules/settings_tray_test/src/Plugin/Block/ValidationErrorBlock.php

Namespace

Drupal\settings_tray_test\Plugin\Block

File

core/modules/settings_tray/tests/modules/settings_tray_test/src/Plugin/Block/ValidationErrorBlock.php

View source
<?php

namespace Drupal\settings_tray_test\Plugin\Block;

use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Provides a 'Block with validation error' test block.
 */
class ValidationErrorBlock extends BlockBase {
    
    /**
     * {@inheritdoc}
     */
    public function build() {
        return [
            '#markup' => '<span>If I had more time this would be very witty :(.</span>',
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
        parent::validateConfigurationForm($form, $form_state);
        $form_state->setError($form['label'], 'Sorry system error. Save again.');
    }

}

Classes

Title Deprecated Summary
ValidationErrorBlock Provides a 'Block with validation error' test block.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.