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
Found by @Berdir in #2226493-154: Apply formatters and widgets to Node base fields:
It seems, at least for some widgets (seen with DateTimeTimestampWidget in the issue linked above), the structure of the $values received in massageFormValues() is not the same depending on whether the widget was visible or not (#access = FALSE ? to be confirmed by @Berdir)
Steps to reproduce
Needed
Proposed resolution
Remaining tasks
Steps to reproduce
Is the test in #4 sufficient to expose the problem.
Has the problem gone away?
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#4 | 2326533-Widget_massageFormValues-2.patch | 1.46 KB | yched |
#2 | 2326533-Widget_massageFormValues-2.patch | 1.46 KB | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedIIRC, #access FALSE means the the #default_value gets passed directly into form submitted values, right ?
I guess on some widgets that might skip some transformations steps and you end up with varying value structures in massageFormValues() depending on whether the widget was fully processed or not.
Requires more investigation, but maybe there are cases where we want to skip massageFormValues() (random thought, maybe that's not the right fix).
Comment #2
yched CreditAttribution: yched commentedI tried to reproduce by having EntityFormDisplay::buildForm() force #access = FALSE on Node 'created' field,
but I did not run into a case where TimestampDatetimeWidget::massageFormValues() received an $item where $item['value'] was not the expected DrupalDateTime object.
Attaching a test patch to try to run the full test suite on this.
Comment #3
yched CreditAttribution: yched commentedAs a side note, we should really do something about the fact that buildEntity() runs three time on a node form submit :-/
I think I opened an issue long ago, will try to find and bump it.
[edit: that's #1768526: NodeFormController::validate() calls buildEntity() twice ]
Comment #4
yched CreditAttribution: yched commentedI can haz test ?
Comment #6
yched CreditAttribution: yched commentedGreen - so either there is in fact no problem, or we don't have a test that reproduces it.
@Berdir, any recollection of the case where you had issues in #2226493: Apply formatters and widgets to Node base fields ? :-)
Comment #8
mgiffordPatch no longer applies.
Comment #20
quietone CreditAttribution: quietone at PreviousNext commentedThe testing done by @yched suggests that this is no longer a problem but it is not clear what the steps to reproduce this are. Let's see if anyone knows.
@Berdir, do you recall how to reproduce this problem?
Comment #22
quietone CreditAttribution: quietone at PreviousNext commentedNo steps to reproduce have been provided since they were first asked for 8 years ago. I reckon it is time to close this one.
Comment #23
andypostIt needs work to remove TODO at least
Comment #24
andypost