Hi,

I found a need to add a multiple selection menu to user profiles (so they can select different skills they can contribute to projects or events). However this way not possible so I added a new field type 'mutliselect' to the profile.module. I've tested it and it does the job fine for me. You create it just like you would a list selection field but users can select multiple values from the list!

help yourselves to the patch.

ta,
Joe

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Uwe Hermann’s picture

Status: Needs review » Active

That's not a patch. Please provide a proper patch for HEAD.

IamPter’s picture

Version: 4.6.1 » 4.6.3

I think you are asking for the same thing I did here http://drupal.org/node/28089.

DeVill-1’s picture

Version: 4.6.3 » 4.6.6

So is there a patch for this anywhere, or is it just the revised module as listed in the top post?

I'd like to try a patch.

sime’s picture

Version: 4.6.6 » x.y.z
Assigned: joehudson » sime
Category: task » feature
Status: Active » Needs review
FileSize
5.02 KB

Here is a patch on cvs that adds multiselect to the profile field choices.

Selections are saved in a serialized form (as opposed to comma-delimited as per the original submission).

drumm’s picture

Status: Needs review » Needs work

Can we avoid serialized data? Figuring out everyone who made a certain selection isn't fast or fun with string parsing from serialized data in SQL.

sime’s picture

Assigned: sime » Unassigned

Well, the previous version had comma separation rather than serialization. I changed it because I couldn't be sure I wouldn't have commas. What is the preferred method?

drumm’s picture

Add a new table if necessary. If there is older data which is being changed to serialized, that would need a database update to convert.

Ignas’s picture

Nice patch! thanks.
But found strange error: word 'Array' displayed instead items in profile.
Corrected after some changes in profile_view_field function:

	  case 'multiselect':
        $values = split("[,\n\r]", $value);

Changed to

	  case 'multiselect':
        $values = $value;

One more thing. Remove multifield in profile browser is not correct, I think. I made exeption therefore. In
function profile_browse code $result = db_query('SELECT name, title, type, weight FROM {profile_fields} WHERE fid != %d AND visibility = %d ORDER BY weight', $field->fid, PROFILE_PUBLIC_LISTINGS);
changed to $result = db_query('SELECT name, title, type, weight FROM {profile_fields} WHERE fid != %d AND visibility = %d ORDER BY weight', $field->type=='multiselect' ? 99 : $field->fid, PROFILE_PUBLIC_LISTINGS);

Ignas’s picture

Used patch submited by sime on May 15, 2006 - 09:50

sime’s picture

@drumm
So the comma separated is not ideal either. OK, I will look at the extra table idea. I would also like to change the date type so that it is stored as a stamp, but that would require extra care for upgrades methinks. Maybe there are also potential issues with date range of a unix timestamp...

@ignas
Are you in a position to create a new patch so that I can modify drumm's suggestion on top? No dramas if not.

jaxxed’s picture

FileSize
38.35 KB

ABOUT THE SERIALIZED ISSUE:
I don't understand why people think it's more difficult to deal with PHP serialized data, especially in SQL; if anything it's actually easier to avoid false positives and issues with delimiters being used in the fields.
- You can do string searches directly on the serialized data or serialize your search term;
- As long as your data is short, the serialize is very lightweight;
- you could even do funky things like search for all 7 letter string starting with 'sh', even if the data is a serialized array or object.

ADDING NEW TABLES IS A BIT MUCH:
I disagree that adding a new table is required for a particular case of a particular field type of a particular module. I know the weight isn't much for a small table but it clouds the tablespace.

Not to push my own **** too much but I did a serialized solution, that includes controls for choosing multiple selects or checkboxes (radios too) and adds vocabulary/taxonomy based fields (see include.)
The code is about as clean as the original but required too many changes for a simple patch. Man would I ever like to rewrite this module to abstract the field stuff into more modular code (can you imagine how much cleaner it would be.)

Jax’s picture

There are very few situations where a multi-select list is needed. Usually this choice should be replaced with check boxes Having a user select his skills in a form should be handled with check boxes, using a multi-select is a bad idea IMO.

http://alistapart.com/articles/sensibleforms
http://www.siteexperts.com/tips/html/ts16/page1.asp

LAsan’s picture

Version: x.y.z » 7.x-dev

Feature request, moving to cvs.

Junesun’s picture

I absolutely need multiselect in my profiles, and for a very legitimate reason: users are supposed to select the languages they speak, the music styles they like, the interests they have from a pre-defined list (to keep it translateable) and I'm not going to create hundreds upon hundreds of checkboxes for that. So my heartfelt thanks to those who have worked on a solution here!

One more issue: with the patch I applied, i18n_profile can't translate the items from a multiselect selectbox anymore. I need to retain that functionality. Is anybody up to patching i18n_profile for this functionality? I can offer a small compensation, contact me.

izmeez’s picture

Yes, a multi select field in profiles would be useful. I am using Drupal 6.x and would like to be able to use such a field on a site. Any suggestions of how to do this would be appreciated. Thanks,

Izzy

binford2k’s picture

Straight port of #4, with the fix in #8. This applies cleanly to Drupal 6.3.

Problems:

  • Visually unappealing (should be checkboxes)
  • Doesn't work with views
  • Doesn't allow browsing by value

http://lug.wsu.edu/~ben/drupal_multiselect_profile_D6.patch

ernan’s picture

Sorry where/How I add the patch

Dave Reid’s picture

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

This will no longer be relevant with fields in core integrated with profiles. And since feature requests are never backported, I'm closing this issue as won't fix.

linuxeasy’s picture

FileSize
8.84 KB

Hi All,

This is a bit customization on http://drupal.org/project/profile_checkboxes

which makes multiple-select-box on profile page Working.

Sorry as i dont know about creating a patch, i have posted a complete module with customization which can be directly enabled/disabled.

This module if used is a fully working and tested one!

Usage is same as you would use profile_checkboxes module. It give you a fourth option of creating a multi-select list-boxe when you create a new profile file which is usually yoursite.com/admin/user/profile/add/selection (see at bottom of this page after module installation).

Please find this module customized at http://drupal.org/files/issues/profile_checkboxes.zip

Thanks!
Linuxeasy!