3
是否有可能以填補在可獲取的選項<select>
的選項域中的constraints
的Grails 3.2.2從域約束選擇選項
static constraints = {
variable(inList: ["value1", "value2", "value3"])
}
是否有可能以填補在可獲取的選項<select>
的選項域中的constraints
的Grails 3.2.2從域約束選擇選項
static constraints = {
variable(inList: ["value1", "value2", "value3"])
}
您可以通過訪問列表:
YourClass.getConstrainedProperties().yourProperty.inList
您可以在g:each
循環中使用此選項來創建您的選擇選項或使用g:select
標籤,因爲:<g:select from="${YourClass.getConstrainedProperties().yourProperty.inList}" />
Thanks @Joshua Moore用於添加g:select標籤作爲替代解決方案,而不是使用g:each。絕對是更好的方式和走的路! – Kloker