Reputation: 173
I'm newbie with Grails framwork. I have issue:
I have Domain is: "Country". And I wants to show list country in select tag by using g:select in Grails
1 England
2 Canada
3 Germany
Now, I wants set "Canada" is selected. Who can help me. Please!
Upvotes: 7
Views: 15117
Reputation: 31
Why not use g:countrySelect
tag? This will save One whole Domain.
Upvotes: 3
Reputation: 6226
Use the select tag structure provided by mpccolorado, then to have Canada selected by default change the value
to:
value="2"
(the Id for Canada).
Upvotes: 1
Reputation: 827
Use the value attribute to set the selected item:
<g:select name="user.company.id"
from="${Company.list()}"
value="${user?.company.id}"
optionKey="id" />
Upvotes: 9