Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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
Comment | File | Size | Author |
---|---|---|---|
#19 | profile_checkboxes.zip | 8.84 KB | linuxeasy |
#11 | profile_7.module | 38.35 KB | jaxxed |
#4 | profile_multiselect.patch | 5.02 KB | sime |
profile_3.module | 24.4 KB | joehudson |
Comments
Comment #1
Uwe Hermann CreditAttribution: Uwe Hermann commentedThat's not a patch. Please provide a proper patch for HEAD.
Comment #2
IamPter CreditAttribution: IamPter commentedI think you are asking for the same thing I did here http://drupal.org/node/28089.
Comment #3
DeVill-1 CreditAttribution: DeVill-1 commentedSo 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.
Comment #4
simeHere 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).
Comment #5
drummCan 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.
Comment #6
simeWell, 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?
Comment #7
drummAdd a new table if necessary. If there is older data which is being changed to serialized, that would need a database update to convert.
Comment #8
Ignas CreditAttribution: Ignas commentedNice patch! thanks.
But found strange error: word 'Array' displayed instead items in profile.
Corrected after some changes in profile_view_field function:
Changed to
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);
Comment #9
Ignas CreditAttribution: Ignas commentedUsed patch submited by sime on May 15, 2006 - 09:50
Comment #10
sime@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.
Comment #11
jaxxed CreditAttribution: jaxxed commentedABOUT 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.)
Comment #12
Jax CreditAttribution: Jax commentedThere 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
Comment #13
LAsan CreditAttribution: LAsan commentedFeature request, moving to cvs.
Comment #14
Junesun CreditAttribution: Junesun commentedI 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.
Comment #15
izmeez CreditAttribution: izmeez commentedYes, 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
Comment #16
binford2k CreditAttribution: binford2k commentedStraight port of #4, with the fix in #8. This applies cleanly to Drupal 6.3.
Problems:
Doesn't allow browsing by valuehttp://lug.wsu.edu/~ben/drupal_multiselect_profile_D6.patch
Comment #17
ernan CreditAttribution: ernan commentedSorry where/How I add the patch
Comment #18
Dave ReidThis 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.
Comment #19
linuxeasy CreditAttribution: linuxeasy commentedHi 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!