Mich
Mich

Reputation: 137

g:select value disappears after populating the select

Im using g:select to that is populated with a list from controller! i pass the selected value as well from the controller when the select changed and submitted !

 <g:select id="select"
           name="select"
           from="${someList}"
           value="${passedParameter_selectedValue}"
           noSelection="${['':'sth']}"
           optionValue='name'
           optionKey="id"
           />

When i debugged it so after submitting the values , my page is refreshed with a list from the controller! so the select has ( Value ) after one iteration then it becomes null !

The thing is it was working good when i didn't use optionKey!

Upvotes: 0

Views: 87

Answers (1)

MKB
MKB

Reputation: 7619

value should be same as optionKey e.g. your optionKey is an id and therefore value should also be an id of the instance. Try

value="${passedParameter?.id}"

Upvotes: 1

Related Questions