When we use this widget with the services module, there are some issues as to how this field is quite different to the core select widget.
The main issue I have is that the NULL or (-None-) selection option is set via the following JSON.
"field_name": {
"und": { "select": "" }
}
Where as the core drupal select list is set as follow for a NULL or (-None-) selection option.
"field_name": {
"und": { "select": "_none" }
}
This might not seem like much but for other systems trying to interact with a REST web service it is difficult to explain why there is a difference.
Also we have found that when setting the value of other to a known value that it gets appended to other rather than falling back to the predefined value though that ticket is open here http://drupal.org/node/1818876.
I would request that we better align with Drupal core's way of handling select input values via REST (in my case i have been using services 3.x).
Comment | File | Size | Author |
---|---|---|---|
#14 | interdiff.txt | 662 bytes | legolasbo |
#14 | align_with_drupal_core-1830090-14.patch | 12.19 KB | legolasbo |
#3 | 1830090-3-align-with-drupal-core-null.patch | 1.83 KB | lathan |
#1 | 1830090-2-align-with-drupal-core-null.patch | 630 bytes | lathan |
Comments
Comment #1
lathanHere is a patch to fix this.
Comment #2
lathanchange status
Comment #3
lathanI should have also altered the saved values back to NULL, this patch fixes that.
Comment #4
haydeniv CreditAttribution: haydeniv commentedPatch looks good to me and everything still appears to work.
Committed to dev commit 22ebcb5.
Thanks!
Comment #5
star-szrUnfortunately this introduced a number of field widget bugs relating to required fields - see screenshot.
The attached patch simplifies the handling of the _none option a bit and does not add an additional option for required fields.
I think some refactoring could be done here to rely more on FAPI, but I wanted to address the bug first, the refactoring could be done in a separate issue.
Comment #6
star-szrSetting correct component.
Comment #7
haydeniv CreditAttribution: haydeniv commentedBlast. That will teach me to get commit happy. Commited #5 commit #354d35f.
Back to needs work for refactoring instead of a followup so we keep the history here.
Comment #8
MrHaroldA CreditAttribution: MrHaroldA commentedI found another issue with the Drupal core transition to '_none'. The attached patch fixes the empty string value in
select_or_other_field_widget_validate
to '_none' to prevent the infamous "An illegal choice has been detected. Please contact the site administrator."-error.I'm not 100% sure, but I think the value of the "none"-option never should be '' (empty string), but '_none' so the widget will need some extra attention. Keeping it at 'needs work'.
Comment #9
haydeniv CreditAttribution: haydeniv commentedLooks like there is still some discussion about this on the core side #1585930: Options module uses '_none' as a special value. I'd like to see where they go with that issue before big form handling changes.
Comment #10
mrfelton CreditAttribution: mrfelton commentedI'm still using 7.x-2.15 with the patch from #3 and I dont have time to do a full update now. But, I do need to fix an issue with that patch where numerical sting keys were being converted to integers as opposed to remaining as strings due to use of array_merge(). Here is the updated version of patch in #3
Comment #11
mthomas CreditAttribution: mthomas commentedMy immediate problem with this is that forms are failing to validate because "_none" is being evaluated by select_or_other_field_widget_validate. Excepting "_none" values from validation works for me, patch attached. Any thoughts on this?
Also, do these lines (starting on 358 in dev) serve any purpose? I don't see where $items is set in the function.
Comment #13
legolasboAttached patch should fix this properly.
I've removed the custom handling of the empty options and use Drupal's functionality, except for the radiobuttons since Core doesn't provide an empty value for those.
Comment #14
legolasboRemoved unnecessary #empty_option assignment. Drupal core adds this when omitted.
Comment #16
legolasboLet's do this refactoring in 3.x
Comment #18
legolasboRewritten empty options from scratch + test coverage.