Needs work
Project:
Drupal core
Version:
11.x-dev
Component:
options.module
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
11 Jan 2014 at 00:40 UTC
Updated:
4 Nov 2026 at 13:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
swentel commentedComment #2
yched commentedThanks for the patch @swentel.
Actually #2170979: remove the getValue() / setValue() dance in WidgetBase::sortItems() might be a better base for this cleanup. Would allow us to move everything into massageFormValues(), including the "make sure $element['#value'] is an array" part the patch still keeps in the validate.
Comment #3
swentel commentedYep, that's what I was thinking too. Let's wait until that one gets in for further cleanup.
Comment #4
yched commented#2170979: remove the getValue() / setValue() dance in WidgetBase::sortItems() is in :-)
Comment #5
swentel commentedYep, I'll reroll tonight
Comment #6
swentel commentedCompletely untested - let's see what the bot thinks :)
Comment #7
swentel commentedtrying without the setValue() in validate - but I'm afraid it won't work
Comment #9
yched commentedHm - right. The $elements generated by the various formElement() implementations can return a string if the field is single-valued (radios / select in single mode).
So we still need to keep an
in validateElement() (with the above explanation as a comment so we don't scratch our heads again ?)
That comment would need to move down and be merged with the "Transpose selections..." code block below.
Comment #10
swentel commentedrerolled, should be good now I think.
Comment #12
swentel commentedComment #13
yched commentedLooks good. Thanks !
Comment #15
swentel commentedSo that didn't fly apparently :)
Comment #16
wim leers@swentel, but I thought this was the case: #2226723: Value changes from WidgetBase::massageFormValues() are discarded?
Comment #25
psf_ commentedThe file
was moved to
And the patch is not applicable.
But I think that the problem persists.
Comment #26
psf_ commentedI built a sample module with a new widget over text (plain) field, with a checkbox to clear it, and a content type with two new fields using this widget, one simple valued and the other multivalued, but massageFormValues is never called.
I attached the module here with the hope that it will is successful.
Comment #38
smustgrave commentedComment #39
smustgrave commentedDisclosure used Claude Code to find my way to extractFormValues() and cleanup my comments for needing to filter out 0 as that was breaking checkbox tests.
Comment #40
dcam commentedI left two comments. Setting the status to Needs Work to get answers to the questions.
Otherwise, I think the changes are probably OK. But I haven't done a really deep dive yet, like setting up fields and watching the values in a debugger.
Comment #41
smustgrave commentedTried my best to answer
Comment #42
dcam commentedI think this is OK to go. I performed the manual testing of Options widgets that I said I hadn't done yet in #40. I tried to test as many scenarios as I could think of, including single and multiple options, required and not required, and the two subclass widgets of the base (select list and checkbox/radio). After each save I checked the field's table contents in the database to verify that the resulting saved data matched what was expected from the main branch. I didn't notice any issues.
Comment #43
quietone commentedI read the issue and the MR and updated credit. I didn't find anything amiss.
Comment #46
catchCame here expecting this to remove some code, while it's a net addition, however other widgets in core do indeed implement this method and it's on the interface, so makes sense to do it for consistency.
Committed/pushed to main and 11.x, thanks!
Comment #48
joelpittetI am currently trying to get D12 for conditional_fields working and apparently we were relying on/working around this side-effect. Good to be consistent though, I think we can fix it there! #3596497: Automated Drupal 12 compatibility fixes for conditional_fields 4.x-dev. If anybody else in contrib is doing the same, that might help them (assuming I succeed), at least a cautionary tale either way... 🐉
Comment #50
berdirIt also looks like this broke select2: #3635276: Drupal 11.5: InvalidArgumentException: Value is not a valid entity.
This didn't come with any tests I don't think it fixes any specific bugs that other subclasses haven't already worked around?
Should we revert this to make it more defensive so it doesn't break contrib use cases?
Comment #51
catchLet's revert and see what we can do, we can always revert the revert.
I've reverted from main and 12.0.x, but for whatever reason the 11.x revert doesn't apply cleanly so we'll need an MR for that.
Comment #54
smustgrave commentedIsn’t this exposing something wrong with select2 though?