The attached patch against DRUPAL-6-9 allows the Profile module's field type "list selection" to optionally add a label to an option. For example, instead of specifying the Selection options
AT
BE
BG
one can specify
AT|Austria
BE|Belgium
BG|Bulgaria
so the actual selection menu offers the country names
Austria
Belgium
Bulgaria
to choose from, but actually sets the country code to that field. This can be useful for instance if you synchronize user data via LDAP from/to other CMSes like Moodle (Moodle actually stores these ISO country codes).
My patch is based on the code posted by user "Bacteria Man" at http://drupal.org/node/35249 and ported to Drupal 6.x.
Comment | File | Size | Author |
---|---|---|---|
#18 | profile-375307-18.D6.patch | 2.81 KB | roball |
Comments
Comment #1
brianV CreditAttribution: brianV commented+1 for this feature. However, it needs to go into 7.x first.
Comment #3
BioALIEN CreditAttribution: BioALIEN commentedJust came across this much needed feature. Can we add support for null values in case we want to have required fields and don't want to preselect the first item in the options. Here's an example:
--|Please select
-- can denote a null key or
null|Please select
Comment #6
roball CreditAttribution: roball commentedIs this functionality still not added into D7???
Comment #7
roball CreditAttribution: roball commentedHere is an updated patch against the DRUPAL-6 branch. It displays the value (and not the key) if a selection field contains key|value pairs.
Comment #8
dimkin7 CreditAttribution: dimkin7 commentedlabeled_options-DRUPAL-6-9.patch queued for re-testing.
Comment #10
Cyberwolf CreditAttribution: Cyberwolf commentedSubscribing
Comment #11
Damien Tournoud CreditAttribution: Damien Tournoud commentedThe profile module is obsolete. Won't fix.
Comment #12
lane.angelique CreditAttribution: lane.angelique commentedI found a helper module for 6 that adds a blank "Please Select" to the top of the list:
http://drupal.org/node/31411#comment-2266426
Comment #13
sebas5384 CreditAttribution: sebas5384 commentedlabeled_options-DRUPAL-6-9.patch queued for re-testing.
Comment #14
roball CreditAttribution: roball commentedAttached is the updated patch in new Git compliant -p1 format.
Comment #15
chinita7 CreditAttribution: chinita7 commentedThanks. The patch #14 works on my site.
Comment #16
roball CreditAttribution: roball commentedThen I think we can change the status to RTBTC, however I don't think this will ever go to D6. For D7 it is obsolete.
Comment #17
kjventura CreditAttribution: kjventura commentedIf you are having this error: (Notice: Undefined offset: 1 in profile_view_field() (line 268 of C:\xampp\htdocs\bgn\modules\profile\profile.module))
Add the isset to $parts[1]
Comment #18
roball CreditAttribution: roball commentedRight, new patch attached. kjventura, could you please confirm that it works as expected?
Comment #19
roball CreditAttribution: roball commentedComment #20
roball CreditAttribution: roball as a volunteer commentedD6 has reached EOL, thus changing this issue's status to Won't fix.