0

In my grails project i want to implement a drop down list. As we define, String priorityType in the domain class,

it generated as a normal text field to input data. I want to know how define stage as a dropdown list which would contain premium, bold as its drop down values If can please help me for this

  • 1
    this link shows how to create a dynamic dropdown list http://java.dzone.com/articles/grails-dynamic-dropdown –  May 20 '13 at 06:51

1 Answers1

0

As usual dropdown used for relations. Create a domain PriorityType and define instead of String priorityType reference to this domain PriorityType priorityType.

In other case you can create a dropdown from enum values. Here the example:

 <div class="fieldcontain ${hasErrors(bean: shoppingCenterInstance, field: 'activityState', 'error')} required">
    <label for="activityState">
        <g:message code="shoppingCenter.activityState.label" default="Activity State"/>
        <span class="required-indicator">*</span>
    </label>
    <g:select name="activityState" from="${ActivityState?.values()}"
              keys="${ActivityState.values()*.name()}" required=""
              value="${shoppingCenterInstance?.activityState?.name()}"/>
</div>

See also this question how to use select+enum

Community
  • 1
  • 1
Mr. Cat
  • 3,522
  • 2
  • 17
  • 26
  • can we use enum eg:class Category{ Type type enum Type{ GENERAL, BOLD } } – user2362045 May 21 '13 at 07:19
  • see http://stackoverflow.com/questions/11126340/using-value-of-enum-in-gselect-when-enum-is-attribute-of-selection-object how to use enum – Mr. Cat May 21 '13 at 07:40