Add validation to config form

Created on 6 March 2024, 4 months ago
Updated 25 March 2024, 3 months ago

Problem/Motivation

Currently the config page makes it possible for people to submit a default user who does not exist, or specify a path to a module that does not exist. The descriptions change to tell of a problem, but it would be better if the validation failed.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States swirt Florida

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @swirt
  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida

    example:

      /**
       * {@inheritdoc}
       */
      public function validateForm(array &$form, FormStateInterface $form_state) {
        if ($form_state->getValue('example') != 'example') {
          $form_state->setErrorByName('example', $this->t('The value is not correct.'));
        }
        parent::validateForm($form, $form_state);
      }
    
Production build 0.69.0 2024