Widget doesn't validate against field constraints

Created on 11 March 2021, over 3 years ago
Updated 22 February 2023, over 1 year ago

Problem/Motivation

Currently the widget ignores field-level constraints when processing entered values. As a result, values can be saved even if they don't pass constraint validators that should affect them.

Steps to reproduce

- Create your own Constraint that affects one of the fields in a given paragraph type. (You can reproduce this without coding by installing a module that provides this type of functionality, for example creating a paragraph type with an entity reference field, and then using the https://www.drupal.org/project/entity_reference_validators β†’ to prevent duplicates on that field)
- Using the Layout Paragraphs widget, enter some content in the field that should fail validation.
- Save the form
- EXPECTED: Validation should kick-in and the form shouldn't be saved
- ACTUAL: The form is saved and no validation error is displayed

If you repeat the same operation, but this time using paragraph's own widget, the validators are applied as expected.

Proposed resolution

Call all field-level validator constraints when processing values in the widget.

Remaining tasks

Write the code, test and review.

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain marcoscano Barcelona, Spain

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.

Production build 0.71.5 2024