1

I want to make an editable g:select in grails. I have an g:select with my default values but I want to can add some from hand. How can I do that?

krolik1991
  • 244
  • 1
  • 4
  • 13
  • Take a look at http://stackoverflow.com/questions/740195/adding-options-to-a-select-using-jquery-javascript – saw303 Oct 16 '14 at 11:07

1 Answers1

-1
<g:select name="selectName" from="${yourValue}"
              optionKey="field" optionValue="field" class="form-control" noSelection="['': '']" value="${defaultValue}"/>

optionKey="field" -- if you have an list of objects(view) optionValue="field" -- if you have an list of objects(send to server)

in from u can add something like this:

from="${["1","2","3"]}"
Koloritnij
  • 1,167
  • 1
  • 8
  • 15
  • How does this answer the question? I don't think that the given example allows the user to add a new option that is not specified by the values of the 'from' attribute. – gogognome Apr 03 '15 at 13:12
  • Elementary. His question was: how can I add my own value to g:select? Answer: – Koloritnij Apr 04 '15 at 08:48
  • I was under the impression that the question was how to make a g:select where the user has the possibility to add a new value. So you get a sort of input field where the user can pick an option from a combobox and enter a new value. – gogognome Apr 06 '15 at 09:42