how to enable multi select for user profile select list

vj0914 - May 2, 2008 - 13:14

I created a new field in user profile with select list, but I can't multi select options, is there a way to enable that?

I don't believe the core

WorldFallz - May 2, 2008 - 13:19

I don't believe the core profile module has this ability.

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

I am trying to hand-coded to

vj0914 - May 2, 2008 - 13:20

I am trying to hand-coded to enable this feature, not sure where to find the code generates the select box

Altering core modules is a

WorldFallz - May 2, 2008 - 13:49

Altering core modules is a bad idea and nearly everyone who does so regrets it (after it's too late). You will be on your own maintaining, upgrading, and securing the module once you do this. That said however, the code should be in profile.module in the /modules directory.

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

is there a way to enable

vj0914 - May 2, 2008 - 14:34

is there a way to enable that without changing the core

We're going in circles

WorldFallz - May 2, 2008 - 14:55

We're going in circles here--- see my first response.

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

maybe, I'm looking too

hhanna - May 23, 2008 - 19:33

I'm using drupal 6.

I'm trying to add a multiple select list too. But I can't seem to find a way to have drupal handle the returned array properly.

Using the profile.module and the drupal administer interface I created a selection list named "profile_interests" and added it to the user registration form.
Then I built a module called registerForm and implemented hook_form_alter() to modify my form fields.

In my registerForm_form_alter function, I wrote:

<?php
function registerForm_form_alter(&$form, $form_state, $form_id) {
    if (
$form_id == 'user_register' || 'user_profile') {
       
$form['Professional Information']['profile_interests']['#multiple'] = "multiple";
    }
}
?>

Everything looks good, except when I submit the form. Submission causes an error:

warning: mysql_real_escape_string() expects parameter 1 to be string, array given in C:\xampp\htdocs\drupal\includes\database.mysql.inc on line 321.

Since a multiple select field returns an array, I'm stuck on trying to catch and manipulate the posted value before it is sent to the database. So far, I've not had any luck. If I could catch the posted data, I could use the php functions implode/explode to toggle between a string and an array.

If anyone finds a way to implement a multiple selection list in drupal 6, please, please post it.

In my opinion, it is ridiculous that the taxonomy administration page makes use of a multiple select list, but there isn't one availabe in drupal core.

I'd be very interested in

mariusooms - August 20, 2008 - 14:54

I'd be very interested in using your custom module/approach when you figure out how to get it to work properly as I too don't want to touch core. It is just not feasible to show 100 check boxes ;)

Regards,

Marius

another option, which might

WorldFallz - August 20, 2008 - 17:17

another option, which might be easier but is definitely more flexible, would be to use a module like bio (and maybe advanced profile also) to implement user profiles as nodes (thereby gaining access to all of cck for your field and formatting options). Only problem is bio isn't available for d6-- all the d5 profile nodes modules are supposedly being integrated into a single module called content_profile (which does have a beta available).

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

 
 

Drupal is a registered trademark of Dries Buytaert.