Grails 3.2.2从域约束中选择选项

时间:2017-08-10 12:23:48

标签: select grails groovy

是否可以使用域<select>

中的可用选项填充constraints的选项
static constraints = {
    variable(inList: ["value1", "value2", "value3"])
}

1 个答案:

答案 0 :(得分:4)

您可以通过以下方式访问列表:

YourClass.getConstrainedProperties().yourProperty.inList

您可以在g:each循环中使用此选项来创建您的选择选项或使用g:select标记:<g:select from="${YourClass.getConstrainedProperties().yourProperty.inList}" />