i have <g:select>
in 1 of gsps looks this:
<g:select id="location" name="criteria.location" from="${example.location.list()}" optionkey="id" required="" value="1" class="many-to-one"/>
the expected result this, right?
expected result:
<select id="location" name="criteria.location" required="" class="many-to-one" > <option value="1" selected="selected" >1st location name</option> <option value="2" >2nd location name</option> <option value="3" >3rd location name</option> <!-- entries omitted --> <option value="49" >49th location name</option> <option value="50" >50th location name</option> </select>
but get? end two selected items. 49th option gets selected well, , cannot begin imagine why! there absolutely no mention of value "49" in code...
actual result:
<select id="location" name="criteria.location" required="" class="many-to-one" > <option value="1" selected="selected" >1st location name</option> <option value="2" >2nd location name</option> <option value="3" >3rd location name</option> <!-- entries omitted --> <option value="49" selected="selected" >49th location name</option> <option value="50" >50th location name</option> </select>
if change value
in <g:select>
"3" example, 3rd option gets selected, whatever reason 49th item still gets selected well.
edit: more bizarre, if change value
property value greater than 49, select works , nth option selected!
update: posted answer detailing how got working, still not understand original behaviour of <g:select>
tag.
does have idea going on here?
grails version: 2.2.0
use value attribute
value="${location ?: 49}"
e.g.
<g:select id="location" name="criteria.location" from="${example.location.list()}" optionkey="id" required="" value="${location ?: 49}" class="many-to-one"/>
Comments
Post a Comment