Multi Select Attribute problem
Permalink 1 user found helpful
I have a page with a multi select attribute with allowing mulit chooses. In my code i retrieve the values with this:
if only one item is check i can check it with this code
but if i have multi items check this does not work. Need to see if "RapidCoolRooms" has been selected?
Frank
$ProjectGroup = $cobj->getCollectionAttributeValue('ProjectGroup');
if only one item is check i can check it with this code
if ($ProjectGroup == "RapidCoolRooms")
but if i have multi items check this does not work. Need to see if "RapidCoolRooms" has been selected?
Frank
Hello ijessup,
i am having the same problem. i tried your code, but it doesn't work.
i have changed my select attribute to allow multiple options to be chosen.
When 2 or more options are selected at the same time, only the first selected option is working. How do I make my filter check for all the selected options. ?
Here is my code:
Thank you in advance.
i am having the same problem. i tried your code, but it doesn't work.
i have changed my select attribute to allow multiple options to be chosen.
When 2 or more options are selected at the same time, only the first selected option is working. How do I make my filter check for all the selected options. ?
Here is my code:
Thank you in advance.
Hi,
Try this, it may help
You need to implode the values while storing in database and then explode while checking and viewing.
OR
Just use foreach and If statement within the foreach to check the values.
Hope you understand
Try this, it may help
You need to implode the values while storing in database and then explode while checking and viewing.
OR
Just use foreach and If statement within the foreach to check the values.
Hope you understand
Hello OpenJuiceVijay,
Thank you for your answer.
That might help me solve my problem. :)
Thank you for your answer.
That might help me solve my problem. :)
Hey 87up - did you get my response in the Services forum? There's some example code and a full explanation in there...
Jon
Jon
do you have a link to this?
I posted it in the Service Partners forum, but I'll copy it below for reference:
Try this:
As a way of explanation:
$cobj->getCollectionAttributeValue('myValue') returns an object of all selected options with several methods to traverse through them. '->current()' returns the current selected option, which will always be the first selected option, unless you have used a method like '->next()' or '->rewind()'. There is also a '->contains()' method, but I haven't checked what needs to be passed into that yet.
Jon
Try this:
foreach ($cobj->getCollectionAttributeValue('kompetencer') as $option): if ($option == $c->getCollectionName()): // do stuff... break; endif; endforeach;
As a way of explanation:
$cobj->getCollectionAttributeValue('myValue') returns an object of all selected options with several methods to traverse through them. '->current()' returns the current selected option, which will always be the first selected option, unless you have used a method like '->next()' or '->rewind()'. There is also a '->contains()' method, but I haven't checked what needs to be passed into that yet.
Jon
Hello jbs,
Yes I got your response in the Service Partners forum. It works like a charm.. Thank you for that. :)
Yes I got your response in the Service Partners forum. It works like a charm.. Thank you for that. :)
Where \n is PHP's new line phrase
You need to do something along the lines of: