Grails 3.2.2 从域约束中选择选项



是否可以用域constraints中的可用选项填充<select>的选项

static constraints = {
variable(inList: ["value1", "value2", "value3"])
}

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

YourClass.getConstrainedProperties().yourProperty.inList

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

最新更新