0

Hello how can I set to this dropdown menu to have default value Second from the list?Here is the dropmenu

<g:select name="dropmenu" from="${["First", "Second", "Third"]}"
           />
Lara
  • 9
  • 3
  • Refer this question it shows how to set value for grails select [http://stackoverflow.com/questions/38585489](http://stackoverflow.com/questions/38585489/grails-noselection-property-in-the-select-tag-over-rides-the-value/38587784#38587784) –  Nov 10 '16 at 09:10

2 Answers2

0
<g:select selected="Second" name="dropmenu" from="${["First", "Second", "Third"]}"
       />

Credit: https://stackoverflow.com/users/1583/oded

Set Default Text in a Select (drop-down) box/menu

Community
  • 1
  • 1
borbesaur
  • 681
  • 4
  • 10
0

You are missing the value= attribute. Below is an example that also shows the noSelection option for when the value is null.

            <g:select id="initialOutcome" name="initialOutcome.id" optionKey="id" from="${OutcomeDescription.findAll())}"
                  value="${outcome?.initialOutcome?.id}" noSelection="['':'-Select-']" class="form-control" title="Initial Outcome" required=""/>
Joe
  • 1,219
  • 8
  • 13