i install templates in grails 3 and files are in src/main/templates/scaffoldind works fine but use tag
<f:all bean="${propertyName}"/>
I need a bootsrap twitter class on all inputs and f:all tag do not allow this function, so i need replace tag with individual fields, something like:
<%
props.each{
%>
<f:field bean="${propertyName}" property="${it.name}">
<g:textField name="${it.name}" value="${propertyName}?.${it.name}" class="form-control" />
</f:field>
...
<%
}
%>
I found this article http://www.jakusys.de/blog/2008/12/grails-scaffolding-in-depth/ but is for grails 2 not grails 3, some solution for replace f:all tag for normal inputs or add class "form-control" to all f:all inputs
If you want to make all fields rendered by <f:all />
look nice and bootstrappy, you'll need to create _field.gsp
templates for them.
You can create common templates (used for all fields) by creating these four gsp fragments:
_wrapper.gsp
_widget.gsp
_displayWrapper.gsp
_displayWidget.gsp
in this directory:
grails-app/views/_fields/default/
You can then replace the
<%
props.each{
%>
<f:field bean="${propertyName}" property="${it.name}">
<g:textField name="${it.name}" value="${propertyName}?.${it.name}" class="form-control" />
</f:field>
...
<%
}
%>
bit in your scaffolding gsp with a call to the <f:all />
tag.
See documentation here
This doesn't work for <f:display bean="${propertyName}" />
with me when I was trying to show all properties (without editing), so here is what I did to get works properly, I've created two files the first /views/_fields/default/_displayWidget.gsp
with this template:
<tr class="prop">
<td valign="top" class="name">${label}</td>
<td valign="top" class="value">${value}</td>
</tr>
and the second /views/templates/_fields/_list.gsp
using this template:
<g:each in="${domainProperties}" var="p">
${body(p)}
</g:each>
Actually I've just overwrite the original template _list.gsp (I'm using grails v3.1).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With