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.
There is no '- None -' option in the countries list.
You may not need to fill the country in certain cases. If it is, then you already have de standard field option to set the field to 'Obligatory'.
Comment | File | Size | Author |
---|---|---|---|
#13 | countries-hook_options_list-1079864.patch | 1.78 KB | webflo |
#5 | countries-none-options-field-settings--1079864-4.patch | 1.64 KB | webflo |
#3 | countries_1079864_3.patch | 6.04 KB | johnv |
Comments
Comment #1
Alan D. CreditAttribution: Alan D. commentedI've added one to the country element if it is not required. I'll hook this up latter to the field settings:
Committed to master, and the issue is postponed to remind me to add field setting options latter.
Comment #2
Alan D. CreditAttribution: Alan D. commentedComment #3
johnvHi Alan, continuing on #1090416: Add 'checkboxes/radiobuttons' widget, where a checkboxes formatter is added, I propose some rework in your original code. The change above might not be necessary.
1. add widgets as in #1090416: Add 'checkboxes/radiobuttons' widget, these are defaults, and add the any/none-options by themselves.
2. this issue also inserts function countries_options_list($field);
3. we now have lost the continent filters in the new formatters; we can repair this by moving the settings from the widget to the field:
4. some more details are in the patch.
5. The 'size' option is still lost.
N.B. the patch may not apply cleanly, since I am working on 3 issues, and my not meet the commenting standards, but i have a very basic IDE.
Comment #4
johnvI shouldn't do this too late in the evening. The patch does not save the field settings.
Let me know if you are interested in the change, and if I need to work on it a bit more.
Comment #5
webflo CreditAttribution: webflo commentedHi i reworked this patch and introduced field settings rather than widget settings. This patch provides two core widget (selectbox and checkboxes/radios) as in #1090416: Add 'checkboxes/radiobuttons' widget and fixes the continent filter issue.
The size option is still available but not used in drupal core widgets.
Comment #6
johnvI like this patch. You have kept the 'country select list', which is good since there is no upgrade path.
With admin/reports/fields people can find wher the countries-field is used, to change the widget
Comment #7
Alan D. CreditAttribution: Alan D. commentedIt looks like you both have been active. I really like the look of the use of hook_options_list(), I did not know of this hook!
If either would like access to git to push these changes into the dev version, contact me via my profile. I can not really review or test things out for the next two / three months as we are hitting the back roads of Peru / Bolivia and have very limited internet access.
Big thanks!
Alan
Comment #8
johnvAlan, have a nice trip. Good to know that you're away. I'll do with the patches meanwhile.
Comment #9
johnvThis is fixed by adapting the default select/radio widgets.
Comment #10
Alan D. CreditAttribution: Alan D. commentedI've just pushed through an update script that will convert the instances that use country widgets to options_list widgets and pull over the first found instance settings into the field settings (if not already set).
@webflo
The recursive continents filter has been simplified and renamed to _countries_checkbox_filter(). I discovered that the $element['#value'] is already filtered.
Comment #12
Alan D. CreditAttribution: Alan D. commentedI think that I've found a minor issue with the code, but for the life of me I can find no documentation on this.
The existing code is:
But I think that the callback should be returning an options list if set. So I think that the valid usage is to not have this function to return the field and parse the options, but to return the results of that function directly. IE:
As I stated in the intro, I can not find the documentation on this and I have no idea how to test this either!
Comment #13
webflo CreditAttribution: webflo commentedLet the options_list_callback handle this instead of adding some special behavior for countries_country_expand in countries_options_list().
Comment #14
Alan D. CreditAttribution: Alan D. commentedLooks good, but maybe this is superseded with the changes in #1292044: Code cleanup and filter changes?
Comment #15
Alan D. CreditAttribution: Alan D. commentedPatch added as part of #1132510: Integration with Entity API / Rules