Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Maese Theobald
Working with "selection list" fields in structure / template
November 23, 2009 2:37 AM
Answer

Maese Theobald

Rank: Junior Member

Posts: 64

Join Date: September 8, 2009

Recent Posts

Hello

Please could you help me in order to get the value of a "selection list" field of a web content structure?

We have some fields of this type in a structure but when we are going to retrieve them in the template, with the getData() method, we get the name of the option, not the value and we'd need to get the "friendly string" we use in the list, not the internal value.

Thanks
Fernanda Nery
RE: Working with "selection list" fields in structure / template
April 28, 2010 2:20 PM
Answer

Fernanda Nery

Rank: New Member

Posts: 1

Join Date: February 8, 2010

Recent Posts

We have exactly the same doubt.
Have you found a solution yet?
Thanks.
Amos Fong
RE: Working with "selection list" fields in structure / template
April 28, 2010 4:41 PM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1844

Join Date: October 7, 2008

Recent Posts

Hi,

Try .getOptions()

You can iterate through the list like so:

 1   <tr>
 2      <td>Sample Multiple Selection List</td>
 3      <td>
 4        <b>
 5#foreach($selection in $sample-multi-selection-list.getOptions())
 6          $selection
 7          <br/>
 8#end
 9        </b>
10      </td>
11    </tr>


http://www.liferay.com/community/wiki/-/wiki/Main/CMS+Template+%28Velocity%29
Francesco Cincotti
RE: Working with "selection list" fields in structure / template
October 1, 2010 3:03 AM
Answer

Francesco Cincotti

Rank: New Member

Posts: 1

Join Date: October 1, 2010

Recent Posts

Hi Amos,

getOptions() is OK for multi-selection lists, but I detected the same issue as Theobald:
when using the (single) selection lists, the getData() method extracts the name of the option instead of the value. I tried with getOptions(), getType(), looping on getChildren() and so on...but didnt't manage to get the value.

Many thanks
Francesco
Alexandre Bénard
RE: Working with "selection list" fields in structure / template
November 10, 2010 9:13 AM
Answer

Alexandre Bénard

Rank: New Member

Posts: 2

Join Date: November 4, 2010

Recent Posts

Hi,

I also confirm that getData() for a simple-selection-list return the name of the option and not the value (liferay version 6.0.5 CE).
It's seem related in the LPS-13737 issue.
I think the best will be to have access to key and value with a getKey() and getData() for exemple.

Alexandre
Michael Lauterbach
RE: Working with "selection list" fields in structure / template
June 12, 2013 10:25 AM
Answer

Michael Lauterbach

Rank: New Member

Posts: 4

Join Date: April 2, 2013

Recent Posts

Did anyone find a way to do this?
Luca Lauretta
RE: Working with "selection list" fields in structure / template
October 5, 2013 9:03 PM
Answer

Luca Lauretta

Rank: New Member

Posts: 3

Join Date: December 10, 2012

Recent Posts

Amos Fong:
Hi,

Try .getOptions()

You can iterate through the list like so:

 1   <tr>
 2      <td>Sample Multiple Selection List</td>
 3      <td>
 4        <b>
 5#foreach($selection in $sample-multi-selection-list.getOptions())
 6          $selection
 7          <br/>
 8#end
 9        </b>
10      </td>
11    </tr>


http://www.liferay.com/community/wiki/-/wiki/Main/CMS+Template+%28Velocity%29


Your answer is about "multiple selection list" as it states in your example, and does not apply to the "selection list".
Could you help us with a solution for the "selection list" problem?