fields
fields copied to clipboard
Support Bootstrap 5 in scaffolding templates without requiring fields template files
All generated Grails apps use Bootstrap. So why have a lot of unnecessary css rules and custom classes that cause nothing more that confusion for the developer? I have created new templates for Bootstrap 5 that have virtually no css rules, but require updates to the fields plugin so that fields templates are not also required.
There are also some general things that the fields plugin should change such as:
- Constantly render double quotes.
- User wrapper attributes when rendering the default wrapper.
src/main/templates/scaffolding/edit.gsp
<f:all bean="domain" />
generates several wrappers
grails-app/views/_fields/default/_wrapper.gsp
<div class='fieldcontain'>
<label for='${(prefix?:'')}${property}'>
<g:if test="${required}"><span class="required-indicator"> *</span></g:if>${label}
</label>
${wdiget}
</div>
A bootstrap friendly version would allow modified <f:all />:
<f:all bean="domain" class="row" requiredClass="mb-3 required" labelClass="col-sm-2 col-form-label text-sm-end" divClass="col-sm-10" widget-class="form-control" widget-invalidClass="is-invalid" />
<f:all bean="domain" class="row" requiredClass="mb-3 required"
labelClass="col-sm-2 col-form-label text-sm-end" divClass="col-sm-10" widget-class="form-control" />
<div class="row${required?' mb-3 required':''}${invalid?' invalid':''}">
<label class="col-sm-2 col-form-label text-sm-end" for="${(prefix?:'')}${property}">${label}<g:if test="${required}"><span class="required-indicator"> *</span></g:if>
</label>
<div class="col-sm-10">${wdiget}</div>
</div>