Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Currently, the paragraph entity is built and validated in \Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget::elementValidate() but certain changes only happen after that in massageFormValues(), specifically the behavior settings as well as some language shuffling.
That means it is not possible to write validation constraints based on the behaviors
Proposed resolution
Move the validate call down into massageFormValues(), right before the needsSave(TRUE) call.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#4 | paragraphs-validate-2935186-4.patch | 2.04 KB | Berdir |
| |||
#2 | paragraphs-validate-2935186-2.patch | 1.05 KB | Berdir |
Comments
Comment #2
BerdirLets see if anything complains about this.
Comment #4
BerdirThat patch passed the wrong form part to the validate function, this should be better.
Also added support to show validation errors on the correct behavior settings form element.
Comment #5
BerdirComment #6
miro_dietikerIf we are moving the validation of these elements away from elementValidate into massageFormValues, why can the Behavior validation still stay here?
Comment #8
miro_dietikerDiscussed, looks good...
But yeah, we should once look better why we need these elementValidate and massageFormValues as both then do extractFormValues.. See issue i created.
Thus, committed, thx! :-)