PDA

View Full Version : DataAssist Multiple Search same field


siteontime
06-03-2009, 05:02 PM
I don't know what I am doing wrong, but I cannot get the multiple select list search to work.

I used the dataassist wizard to create a search and results page. I chose menu as the search option.

After the wizard was complete, on the search page I changed the menu to list and checked the allow multiple optiion.

I only get a list of first item selected. How can I get it to include all selections. The URL shows all 3.

HELP!!

I must be missing a step

Ray Borduin
06-04-2009, 08:05 AM
Go to the results page and update the Search server behavior. Make sure it is specified as a type "list" in that interface. I think the Wizard does all type Value or Edit searches regardless of the form element because it doesn't directly support multiselect lists.

Should just be a matter of updating it in the server behavior at this point.

siteontime
06-04-2009, 08:30 AM
No it is set to list. Here is the code.
$WADbSearch2_DefaultWhere = "";
if (!session_id()) session_start();
if ("" == "") {
$WADbSearch2 = new FilterDef;
$WADbSearch2->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch2->addComparisonFromList("minor_class_code","Category2","AND","=",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch2_LaundryProducts"]=$WADbSearch2->whereClause;
}
}
else {
$WADbSearch2 = new FilterDef;
$WADbSearch2->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch2_LaundryProducts"]) && $_SESSION["WADbSearch2_LaundryProducts"] != "") {
$WADbSearch2->whereClause = $_SESSION["WADbSearch2_LaundryProducts"];
}
else {
$WADbSearch2->whereClause = $WADbSearch2_DefaultWhere;
}
}
else {
$WADbSearch2->whereClause = $WADbSearch2_DefaultWhere;
}
}
$WADbSearch2->whereClause = str_replace("\\''", "''", $WADbSearch2->whereClause);
$WADbSearch2whereClause = '';

Ray Borduin
06-04-2009, 10:26 AM
In php you need to add square brackets to the list name in your html before it will work with multiselect.

So <select name="myname"> needs to be updated to <select name="myname[]">

It appears the code is correct, so the problem has to be in the way the form element is named.

siteontime
06-04-2009, 10:38 AM
Thank you Ray, that was the problem!! It was missing in the search page. Is it supposed to do that automatically? Maybe a bug?

Ray Borduin
06-04-2009, 10:53 AM
It only needs to be added for multiselect lists. Since you changed it to a multiselect list, that is when you should have added the brackets. This is a general php thing. Any time you use a multiselect list in php you need to add brackets or it won't work. I suppose we could add them by default, but this is something you will need to know in general when working with multiselect lists in php (or checkbox groups).

drostenator386534
08-10-2009, 10:05 PM
I've just spent two days looking for that answer. 2 little brackets. so simple. Thanks.

nickj
11-03-2010, 07:49 AM
Can you point me to a tutorial or video or PDF which details multi select? Not sure where to find and how to apply.


Thanks

Nick