Fórum

get multiselect selected values in velocity

juan meza, modificado 8 Anos atrás.

get multiselect selected values in velocity

Regular Member Postagens: 228 Data de Entrada: 06/01/14 Postagens Recentes
Hi, I have liferay 6.2 GA4

I have a dynamic data list, and in my structure i have a select, with the multiselect option on...
i want to do a template... but i cant find how to iterate the multiselect selected values...

so far i have:
$cur_record.getFieldValue("SelectRoles", $locale)

this prints the values as an array - ["value1","value 2"]

I need to iterate, maybe something like this:
#foreach($selectRole in $cur_record.getFieldValue("SelectRoles", $locale))
    	        $selectRole.getName()
    	    #end


what am i missing?

thank you
thumbnail
Harish Kumar, modificado 8 Anos atrás.

RE: get multiselect selected values in velocity

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
try this


#foreach($selectRole in $cur_record.getFieldValue("SelectRoles", $locale))
    $selectRole
#end
juan meza, modificado 8 Anos atrás.

RE: get multiselect selected values in velocity

Regular Member Postagens: 228 Data de Entrada: 06/01/14 Postagens Recentes
Hi Hasrish, thank you
I tried your option but it didnt work emoticon
I checked and
#foreach($selectRole in $cur_record.getFieldValue("SelectRoles", $locale))

this does not even iterate... i try to write just a random letter... and it doesnt do anything...

#foreach($selectRole in $cur_record.getFieldValue("SelectRoles", $locale))
                1
            #end


but if i put this alone, it does print the value i mentioned
$cur_record.getFieldValue("SelectRoles", $locale)

it prints exactly this: ["Administrator","User"]


do you know why? any ideas i can try?
juan meza, modificado 8 Anos atrás.

RE: get multiselect selected values in velocity

Regular Member Postagens: 228 Data de Entrada: 06/01/14 Postagens Recentes
did not figure this out, i think its a string with all the values, not an array...so the iteration wont work..
so i did an indexOf just searching for my values... thats what i needed anyway... just to know if the value was inside of one of the selections