在 documentation changelog of the plugin ,在版本 1.1 中,我们可以读到:
Support `widget:'textarea'` constraint.
Grails 有一个 textArea 字段。这是 grails documentation 的示例:
<g:textArea name="myField" value="myValue" rows="5" cols="40"/>
但是,如果我们使用 Grails Fields Plugin,并且我们有如下代码:
<f:field bean="popularExpressionsInstance" property="omg" />
我们如何将其转换为 textArea 以允许输入多行文本?
最佳答案
在您的 popularExpressions
域类中,为 omg
添加以下约束
static constraints = {
...
omg widget: 'textarea'
}
注意:如果您需要控制文本区域的样式,则需要将其包含在 f:field
标记的正文中,例如
<f:field bean="popularExpressionsInstance" property="omg">
<g:textArea name="omg" cols="40" rows="5" maxlength="40" value="some default text"/>
</f:field>
关于grails - 如何更改 f :field (textField) by a textArea using Grails Fields Plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18678596/