class ValidationErrorBlock

Same name in other branches
  1. 9 core/modules/settings_tray/tests/modules/settings_tray_test/src/Plugin/Block/ValidationErrorBlock.php \Drupal\settings_tray_test\Plugin\Block\ValidationErrorBlock
  2. 10 core/modules/settings_tray/tests/modules/settings_tray_test/src/Plugin/Block/ValidationErrorBlock.php \Drupal\settings_tray_test\Plugin\Block\ValidationErrorBlock
  3. 11.x core/modules/settings_tray/tests/modules/settings_tray_test/src/Plugin/Block/ValidationErrorBlock.php \Drupal\settings_tray_test\Plugin\Block\ValidationErrorBlock

Provides a 'Block with validation error' test block.

Plugin annotation


@Block(
  id = "settings_tray_test_validation",
  admin_label = @Translation("Block with validation error")
)

Hierarchy

Expanded class hierarchy of ValidationErrorBlock

File

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

Namespace

Drupal\settings_tray_test\Plugin\Block
View source
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. Please save again.');
    }

}

Members

Title Sort descending Modifiers Object type Summary
ValidationErrorBlock::build public function
ValidationErrorBlock::validateConfigurationForm public function

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