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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brianV’s picture

Version: 6.9 » 7.x-dev

+1 for this feature. However, it needs to go into 7.x first.

Status: Needs review » Needs work

The last submitted patch failed testing.

BioALIEN’s picture

Just 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

Status: Needs work » Needs review

Re-test of labeled_options-DRUPAL-6-9.patch from comment @comment was requested by jww2nc.

Status: Needs review » Needs work

The last submitted patch, labeled_options-DRUPAL-6-9.patch, failed testing.

roball’s picture

Is this functionality still not added into D7???

roball’s picture

Title: labeled options in selection field of profile.module » Allow key|value pairs in selection fields of profile.module
FileSize
2.51 KB

Here 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.

dimkin7’s picture

Status: Needs work » Needs review

labeled_options-DRUPAL-6-9.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal-6.x_profile.key-value-pairs.375307.patch, failed testing.

Cyberwolf’s picture

Subscribing

Damien Tournoud’s picture

Status: Needs work » Closed (won't fix)

The profile module is obsolete. Won't fix.

lane.angelique’s picture

Version: 7.x-dev » 6.x-dev

I 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

sebas5384’s picture

Status: Closed (won't fix) » Needs review

labeled_options-DRUPAL-6-9.patch queued for re-testing.

roball’s picture

Attached is the updated patch in new Git compliant -p1 format.

chinita7’s picture

Thanks. The patch #14 works on my site.

roball’s picture

Status: Needs review » Reviewed & tested by the community

Then 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.

kjventura’s picture

If 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]

if (isset($parts[1]) && $parts[0] == $value) {
   $value = trim($parts[1]);
   break;
}
roball’s picture

Assigned: Unassigned » roball
Status: Reviewed & tested by the community » Needs review
FileSize
2.81 KB

Right, new patch attached. kjventura, could you please confirm that it works as expected?

roball’s picture

roball’s picture

Status: Needs review » Closed (won't fix)

D6 has reached EOL, thus changing this issue's status to Won't fix.