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?

Comments

WorldFallz’s picture

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

vj0914’s picture

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

WorldFallz’s picture

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

vj0914’s picture

is there a way to enable that without changing the core

WorldFallz’s picture

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

hhanna’s picture

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:

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.

mariusooms’s picture

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

WorldFallz’s picture

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

zmove’s picture

I don't like to hack the core, but installing a module that make profile as node, that can completely change you conception and the way things are managed is not a better solution IMHO.

The best things would be to submit a patch that correct all the design errors of the profile module (multiple select, multiple checkbox, etc...) and convain the core team to submit it. Because claiming Drupal is a community oriented CMS without a decent profile module is just anecdotic...

WorldFallz’s picture

There's nothing wrong with the current profile module for what it is, the same with the core aggregator and forum modules. Core modules are always less feature rich, albeit fully functional, than their contributed counterparts. When views makes it into core, it won't be the complete views contrib module-- it will only be certain parts of it deemed the "base". There will always be a views contributed module for advanced functionality.

For a large segment of drupal users, the core profile module is fine-- especially with the new views2 integration available in d6. Users are users and the core profile module is meant to be able to add some fields for storing some basic additional user info not for turning users into first class objects (nodes).

There's no reason to require the overhead and complexity of user profiles as nodes in sites where the user is NOT considered a first class piece of content. That is precisely the type of functionality that is supposed to be addressed by contributed modules.

And there are decent profile modules-- both bio and nodeprofile for d5 were excellent modules, and not hacks. The new content_profile will combine the best features and benefits of both-- hopefully it will become the user profiles as nodes module.

===
"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

daniorama’s picture

Sorry but I have to say that profile really needs to be updated. A profile module without a multiple checkbox and a multiple selection is not complete and not fully functional. Besides profile and content profile do the same but their work completely different, if someone needs something from profile module you cannot just tell them use content profile because many modules won't work then and it may need a total rework of the website. I can understand that profile don't have locations or other advanced features, but having a multiple checkbox and a multiple selection should be a minimum.

I'm using content profile module and it's pretty annoying that many other modules don't work with it. So I try to use it not so often and try to create as many profile fields as possible. The concept of using a contrib module whenever you need more features is pretty nice in theory, but in reality there are multiple modules to do the same thing and many times not all the modules work nicely together. The only way to assure it is improving some of the core modules or not including them so developers don't use them.

That doesn't mean that there should be more core modules, that means that if a core module is not going to accept new features or improvements then it's better not including it anymore. Many developers follow those core modules and it would be better if they don't exist so they would follow just the contributed one and not a less featured core one.

I can tell you some examples about these problems: Forum and advanced forum, profile and content profile. In my opinion forum and profile should be erased, but this will create so many problems upgrading, so they should be improved and if possible merged with their advanced versions.

WorldFallz’s picture

Sorry but I have to say that profile really needs to be updated.

That may be-- and if it's an important feature to you to have those fields be multiselect I'm sure a patch submitted to the issue queue would go a long way toward getting it implemented.

If you mean profiles as nodes in core, that's not likely to happen-- iirc Dries has said that profiles as nodes is not core functionality. That is precisely the reason contributed profiles as nodes modules exist and was architected that way on purpose.

Indeed the very basic philosophy of drupal is to keep core light and tight while not preventing contributed modules from enhancing functionality. See the Why isn't X feature part of core? handbook page for more context to the drupal design philosophy.

I'm using content profile module and it's pretty annoying that many other modules don't work with it

That will change over time-- content_profile has only recently succeeded the d5 bio and nodeprofile modules to become the one-stop-shop profiles as nodes module. This was true of cck and views at one time as well now nearly every contributed module works with both of them.

A lot of people think their use case is "the way" drupal should function. Nary a day passes by that I don't see a post about how drupal "must" do this or 'must' have feature x-- many of which not only disagree but would be incompatible with each other. If drupal included all this functionality it would be a veritable mountain of code that would be impossible to improve and maintain at the speed with which drupal progresses.

That said however, if you truly feel strongly about these things there's nothing to stop you from jumping in and trying to improve drupal-- more than almost any other OS project I know of drupal really is a product of it's community. But it's also very much a meritocracy-- posts or issues of 'do it this way' won't get very far without code, testing, data, or elbow grease to back it up.

===
"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." - Ben Franklin
"Search is your best friend." - Worldfallz

daniorama’s picture

I agree with you, without code we don't go anywhere... :) The good thing is that the code is there for years, just one example http://drupal.org/node/33044 Of course I find the "light and tight" philosophy of Drupal wonderful, but Forum and Profile cores really need a refurbishing.

I'm sure a patch submitted to the issue queue would go a long way toward getting it implemented.

I don't think so, many people have already submitted this feature, but it was never included. I could have this feature in my installation right now. I don't like the idea of hacking a core module but it seems this feature will be never in core and I just ask myself why?

Profiles as nodes is what I don't want to use, the problem is that the lack of very simple things in core profile make me use contrib modules that need a whole new way of structuring profiles. I use content profile for complex things and combining it with many of the cck modules I have installed. I use also profile for the basic ones, that I need to pass to webforms, ubercart and other modules.

I'm not talking about including a "mountain" of features in the profile module, just a multiple select list. If this is not included the only way of having something similar is creating a really long list of checkboxes. I just cannot understand why is not included. There are tons of posts in the forums asking for it since the 4.7 version, but instead of it they include other features that are sweet but not so important (for example having an autofill field in category, I mean, that's nice but it's so important? how many categories can a profile have? 10-20, and even waiting to the category to be "autofilled" takes longer than writing it self)

I totally agree with what you say but about the philosophy of Drupal, but let's not take this out of its context, we are talking about just including a multiselect list, it's not a big deal in code but a huge improvement in usability.

WorldFallz’s picture

I don't think so, many people have already submitted this feature, but it was never included.

I hadn't seen those-- if you could point me to the issues I might be able to figure why and/or what needs to be done to push it. Even though I haven't needed it, I agree with you that it does appear to be a rather simple and useful enhancement.

There are tons of posts in the forums asking for it since the 4.7 version

It's hard to say without seeing the issues to which you refer, but asking for something and providing actual core quality code in the form of patches are two vastly different things. I've seen issue after issue with dozens of "+1"s clogging up the issue and yet no actual code. I've also seen issues that were important enough to someone that they drove it all the way through to implementation.

Obviously I can't say it's always been the case, but most of the issues/feature requests I've seen languishing have either not had anyone drive the code (just a bunch of "+1"s) or lost momentum because the main driver got off the bus so to speak.

...I mean, that's nice but it's so important?

Obviously to the person(s) that drove it to implementation it was. ;-)

we are talking about just including a multiselect list, it's not a big deal in code but a huge improvement in usability.

I agree completely-- and if you point me to the issues you mentioned I'd like to take a look. But as I said above, posts of 'this is important' without code generally don't go anywhere. Most of the time these type of 'must have' features just need a champion.

===
"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." - Ben Franklin
"Search is your best friend." - Worldfallz

zmove’s picture

I know the drupal philosophy is to be light and extensible, and I'm completely agree with that, but we have to make the differences between a design choice and a lack in a module.

In my opinion, multiple select and multiple checkout possibilities for the profile module are a design lack, not a will to make this module "light". It would not increase the module weight by providing these features. The role of the profile module is to add the possibility to add form elements for users, so it should provide all possible form elements you can have in HTML, neither more nor less. Or, maybe providing a system that easily allow to alter that, but that's not the case too.

We are not talking providing users as node, put loud jquery feature etc... The profile module keep his "light" role, but at least, would be complete.

WorldFallz’s picture

i think we all agree in this thread that multi-select fields would be a valuable feature for the core profile module. I can't imagine that a patch for this would have been turned down for philosophical reasons. I could be wrong, but my guess is there's been no code submitted or no one championed its inclusion. But unless i can find the issues mentioned, i can't really say for sure.

as i've said many times before in many threads-- drupal is very much a product of it's community-- anyone can submit patches for core.

===
"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." - Ben Franklin
"Search is your best friend." - Worldfallz

quanders’s picture

I would need this too. I think there is no reason to take each others energy with discussions as the one above.

Would somebody be willing to bring this 5.x patch working on 6.x?
http://drupal.org/node/124348

Thanks a lot in advance.

mohamed_e’s picture

Ok, to finally get this issue done: http://drupal.org/node/334672
There are couple of $$$ to earn for people that port it to the 6.x.

phillamb168’s picture

Just sent the diff and source files to @Quanders - let me know when you've confirmed that it's working.