allow form elements to use validation constraint plugins

Created on 22 August 2019, about 5 years ago
Updated 5 October 2023, about 1 year ago

We have a a great validation system that's reusable and extensible, with validation plugins.

These can be used on entities, and on entity fields.

However, these can't be used on forms!

Something like:

$form['element'] = [
  '#type' => 'textfield',
  '#title' => t('Subject'),
  '#constraints' => [
    'MyConstraintPluginId',
  ],
];
Feature request
Status

Active

Version

11.0 🔥

Component
Form 

Last updated 2 days ago

Created by

🇬🇧United Kingdom joachim

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇮Finland jiisuominen

    +1 for this.

    I understand reasoning here why it's done the way it is, but I'd like to have this as an option for forms too. Now we need to duplicate validations with typed data & forms.

  • Open on Drupal.org →
    Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    Not currently mergeable.
  • @jiisuominen opened merge request.
Production build 0.71.5 2024