Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drumm’s picture

Version: 5.1 » 6.x-dev

No features, such as this, will go into Drupal 5.x.

WeRockYourWeb.com’s picture

Thank you!

Just what I was looking for :) Actually - almost. Best would be the option to have multiple checkboxes. I like the options webform gives me but can't integrate a webform with the user profiles/ registration page. I see that this tutorial explains how to develop a full-fledged user profile in 5.1. Unfortunately I'm still with 4.7 and have a couple modules that aren't 5.1 compatible yet.

Thanks for this!!
Alex

WeRockYourWeb.com’s picture

Update - I just patched your patched profile module with the patch from #9 on this thread, and lo and behold - it works! Multiple select checkboxes for profile/ registration page in 4.7. Sweet!

:)

drupalfan2’s picture

Version: 6.x-dev » 5.1

When activating this patch I get the following error:

warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /home/www/community2/includes/database.mysql.inc on line 400.

Please help me to solve this! Thanx.

drupalfan2’s picture

Problem solved. I forget to delete one line.

drumm’s picture

Version: 5.1 » 7.x-dev

DrupalFan2: Please do not move feature requests to stable versions; they will not be added.

Junesun’s picture

I used this and it worked right out of the box! Thank you so much! I can't believe this wasn't a standard functionality. Just goes to show that Drupal 5.x should probably be named Drupal 1.5.x in terms of maturity... In my list, this goes right next to not being able to translate menus without hacking.

Anyway, now that I patched this, I'm running into a bit of a problem with i18n_profile: i18n_profile allows me to translate the value lists used by the single select, but not the ones used by the multi-select (the rest still works fine). This is probably an easy fix, but I'm not familiar with Drupalese. If somebody can provide this fix quickly, I'm ready to give a small compensation.

vj0914’s picture

Which file should I open to use the patch? I am a newbie. Thanks

vj0914’s picture

I found it,

moshe weitzman’s picture

Status: Needs review » Closed (duplicate)
quanders’s picture

Version: 7.x-dev » 6.x-dev
Status: Closed (duplicate) » Active

Does this work with a 6.x version too? Thanks.

gonzalez_ea’s picture

For what it's worth, I've messed around with bubbasan's patch and made a 6.6 version patch. Actually there are three, because the code has been split into 3 files. I've only been able to test it on localhost, but it works fine.

geraldito’s picture

works fine for me on D6.9. thanx for the patch

tirdadc’s picture

Tried out the patch in #12 on D6.8, seems to work fine. One remaining issue though: the multi-select profile fields cannot be selected as filters in a View. I figure it would require putting together views_handler_filter_profile_multiselect.inc in views/modules/profile to properly process this, but I currently don't have the time to consider developing this. Oh well, back to checkboxes for now.

gonzalez_ea’s picture

FileSize
709 bytes

Aha! Thank you tirdadc, I didn't know where to begin to look to make the multi-select field visible in views. For my purposes, the same handler as for freeform lists was sufficient. If you want to create a new handler, you have to save it in views/modules/profile, modify the handler name in line 209, and then add some code to the function profile_views_handlers() starting on line 236. The patch is for the file views/modules/profile.views.inc

anthrocreative’s picture

Thanks for this patch, it was exactly what I needed! I took it a step further and enabled it for arguments and sorting as well. To make it work for arguments, I had to patch views/handlers/views_handler_argument_string.inc too, which is really an ugly hack.

I'd much prefer to create another handler based on views_handler_argument_string.inc, but I was unable to get Drupal to find the handler -- kept saying "Error: handler for profile_xyz does not exist!" So obviously there's something else to adding a new Views handler (I copied views_handler_argument_string.inc, changed the class name, and made the other code changes needed).

Ultimately, the multi-select values really should be a one-to-many relationship, with one db row for each value. But that's deeper that I'm able get into patching Views at the moment, particularly since I'm not sure how possible it is within the Views framework.

Certainly, any improvements on these patches are welcome.

gonzalez_ea’s picture

Did you add the necessary code in the function profile_views_handlers() starting on line 236? Before I realized I could just borrow the freeform list handler, I created my own and then added an if statement or a case, I don't remember, in this function. Not at first, of course :) I had to see the 'handler does not exist error' about a thousand times before I clued in.

maria_zk’s picture

This is what I get for the drupal 5 path when making a view to display the results for multiple select:
The options that i selected, plus some leading zeros. Example: option1, option2, 0, 0, 0, 0 if i had 6 available options.
Any ideas on how to fix this?

stevekerouac’s picture

This is amazing, thank-you! All seems to be working fine with 6.12.

Gonzalez - I know nothing about PHP but I really need to get this patch working with the 'list selection' handler type, not a completely new handler, but not the 'freeform list' type you have. Would this be simple to do, and if so how?

klokie’s picture

These all work for me in 6.12 as well. Thanks so much!
Seems to me this should be a standard option in the profile module.

jlab’s picture

I totaly agree I really need this functionality... But hate patching sites on my production servers.

Can this be integrated into Drupal 6.x core profile module?

Niko_K’s picture

This should be integrated into the Durpal 6.x (6.13??) core module

pdcarto’s picture

I manually applied the patches in #12 and #16 on 6.12, so I may have made a mistake though I really do not think I did (I've triple-checked each edit). I'm getting wsod after a user submits a profile form with a multi-select field (whether or not an option has been selected). After a this, the profile form is permanently unavailable to that user - the tab doesn't appear (I have two profile tabs: "Personal Info" and "Organization Info"; the multi-select field is in the second; after submitting this form, the "Organization Info" tab is permanently gone). If you try to get to that tab by manually entering the url, you get an access denied.
Strangely, any user who has saved this profile tab gets a wsod upon logout (permanently), while user/1 gets a wsod upon logout after the patches have been applied, whether or not he has saved this profile tab.

I am using the profile_role module, and I wonder if there is some unhappiness in the intersection with these modifications to profile?

I've been struggling to get a look at the php errors - nothing is getting written to the log file I set up, but I may have not set that up correctly.

I'm curious if anyone has any thoughts as to where I should look to figure this out?

stevekerouac’s picture

FileSize
2.22 KB

I was trying to perform Views filtering on multi-select fields. The site allows registered users to tag if they work with certain aspects animation, like 'Flash' or 'Stop-motion' from a list of about 20, using the multi-select profile field. Visitors to the site can then filter the list of users to those who have specified a given tag if they are looking for a certain skill.

I contacted the gonzalez_ea and she kindly responded with the following:

My patch added this code fragment to View's file profile.views.inc.

case 'multiselect':
$data += array(
'help' => t('Profile multi-selection %field-name.', array('%field-name' => $field->title)),
'field' => array(
'handler' => 'views_handler_field_profile_list',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
);

break;

If I'm understanding you, I think all you have to do is to copy the body of the case for 'select' into 'multiselect', like this:

case 'multiselect':
$data += array(
'help' => t('Profile multi-selection %field-name.', array('%field-name' => $field->title)),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_profile_selection',
'fid' => $field->fid,
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);

break;
You might want to get rid of the 'sort' part because I don't see that it makes much sense. I tested it very quickly on a test site of my own, and at the very least it doesn't crap out! I've attached the file for you. Try it out and let me know what happens. Good luck!

She also attached a file profile.views.inc which is uploaded here.

I used the .inc file and it did indeed work. You can see the result here:

http://test.animationeast.com/membersview

Unfortunately, it didn't work quite as I had hoped. In layman's terms:

If a member (listed user with profile) has selected 'Animation 2D' and 'Games' as her tags (from the multi-select list profile field), she will only show up in filtering if the searching user searches for members with BOTH 'Animation 2D' AND 'Games', in fact the filter only returns results which match exactly, so on the page linked to above if you filter for 'Animation 3D' you will get the user 'adrian roper' as that is the only tag he selected. Other users who have 'Animation 3D' AND other tags, get missed out.

Again gonzalez_ea tried to help me:

I've only got time for a short note right now, but it seems to me that what you must do is write a custom filter to achieve the functionality you're looking for.

This is what you have now:

case 'multiselect':
$data += array(
'help' => t('Profile multi-selection %field-name.', array('%field-name' => $field->title)),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_profile_selection',
'fid' => $field->fid,
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);

break;

You'll have to change the handler that's defined in the field 'filter'. There are a bunch of filters that come with Views, maybe one of them will serve, but probably not.

Unfortunately it is way beyond me to solve this as I am not a programmer and I have no idea what a handler is. But I thought someone else may find this code useful, or even know how to fix my problem. All I really need is to change a "IF $X = $Y" to "IF $Y CONTAINS $X" somewhere within Views... I think. But I doubt I'll ever work out where or how.

Boycho Dobrev’s picture

I have the same problem. The query from

... WHERE
profile_values_profile_fieldX.value in('VALUE1','VALUE2')
...

must to be

... WHERE
((UPPER(profile_values_profile_fieldX.value) LIKE UPPER('%VALUE1%')
OR
UPPER(profile_values_profile_fieldX.value) LIKE UPPER('%VALUE2%')))
...

but I do not know where I have to correct the query.

oneoftwo’s picture

Since I really need this feature (as well as #33044: Support for checkbox groups and multi-select lists as a profile field types) on my site, I rewrote/combined/updated my own 5.x module for the purpose, the one provided here by gonzalez_ea, and jsaints's from the other feature request thread (most of the credit is due for those guys, not me). My first attempt at a combined patch can be found in the other thread.

oneoftwo’s picture

Status: Active » Closed (duplicate)

#33044: Support for checkbox groups and multi-select lists as a profile field types
I decided to really mark this a duplicate since the other thread is older and the problem is now "resolved" for HEAD (with won't fix, but still). I also attached a working D6 patch over there.

monto’s picture

Version: 6.x-dev » 6.13
Status: Closed (duplicate) » Needs work

Hi,
I'm using the module "User Import" to import multiple users and get the following error:


    * warning: implode() [function.implode]: Invalid arguments passed in /public_html/modules/profile/profile.module on line 244.
    * warning: implode() [function.implode]: Invalid arguments passed in /public_html/modules/profile/profile.module on line 244.
    * warning: implode() [function.implode]: Invalid arguments passed in /public_html/modules/profile/profile.module on line 244.
    * warning: implode() [function.implode]: Invalid arguments passed in /public_html/modules/profile/profile.module on line 244.

After, I have used the module "Node import" and after finishing all the steps does not matter. Furthermore, in step 4 of 8 say: "Unsupported" field.
Can you help me?

phelix’s picture

Version: 6.13 » 6.14

I have drupal 6.14 and I tried to apply the patch listed to download on this page and it only patches like 3 of the 13 lines. and it completely destroys my drupal install. I get the white page of death on everything. Does this patch not work with this version? Am I doing something wrong? I go into the folder and run patch < patch_40.patch and then everything breaks. Am I doing something wrong?

sakiland’s picture

It works on drupal 6.14. Try to do it manual. There is no much code. I use
profile.admin_.inc_.patch,
profile.module.patch,
profile.pages_.inc_.patch
#12
and
profile.views_.inc_.patch
#15

grendzy’s picture

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

No new features can be added to stable releases. Marking "won't fix" in line with #33044: Support for checkbox groups and multi-select lists as a profile field types.

phelix’s picture

I have this and I am able to view it in the search now. But why is the search field not a multi select? Its just a plain text box. This defeats the purpose doesnt it? Shouldn't this also be a select box? Did I do something wrong?

sol1313’s picture

Thanks gonzalez_ea for the patch! Worked like a charm!

rituraj.gupta’s picture

designcontext’s picture

Is there a solution for the problem written in #24? I have the same and I am very interesseted in a solution but not able to write a handler...

danielbeeke2’s picture

Ha

finaly I fixed it.

I have the solution for #24
I am not really a coder but I managed to fix it.

It involves a hack in view_handler_filter_in_operator.inc

first in the function 'operators' add this

      'like' => array(
        'title' => t('like'),
        'short' => t('like'),
        'short_single' => t('like'),
        'method' => 'op_like',
        'values' => 1,
      ),

than add this
under the function op_simple

function op_like() {
    if (empty($this->value)) {
      return;
    }
    $this->ensure_my_table();
    $placeholder = !empty($this->definition['numeric']) ? '%d' : "'%%%s%%'";

    $replace = array_fill(0, sizeof($this->value),$this->table_alias . '.'  . $this->real_field . ' LIKE UPPER('  . $placeholder . ')' );
    $in = implode(" OR ", $replace);

    // We use array_values() because the checkboxes keep keys and that can cause
    // array addition problems.
    $this->query->add_where($this->options['group'], '(' . $in . ')'  , array_values($this->value));
  } 

next thing to do is going to your view and in the filter options selecting like as the statement.

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

Thanks!
Linuxeasy!

rituraj.gupta’s picture

Issue summary: View changes

Is there any module for Drupal 7 like http://drupal.org/project/profile_checkboxes. I want to integrate with profile module (Not using profile2)