fields icon indicating copy to clipboard operation
fields copied to clipboard

Support Bootstrap 5 in scaffolding templates without requiring fields template files

Open codeconsole opened this issue 1 year ago • 1 comments

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:

  1. Constantly render double quotes.
  2. 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>

codeconsole avatar Sep 06 '24 01:09 codeconsole