grails-fields-plugin/grails-fields

Missing of 'readonly' attribute configurabiltiy!

aadrian opened this issue · 5 comments

The possibility to configure that a field in f:field or more fields in f:all to be readonly seems to be missing :( .

Even if one passes this attibute, it's being ignored :( .

It is very frequent scenario that some fields need to be readonly e.g. when editing vs creating.

Thank you.


Edit on 20-March to clarify:
This issue consists of two parts, both related to the "readonly handling" in this plug-in:

  1. support in <f:all tag, e.g. something like <f:all bean="tableTwo" readonly="['strName','strType', 'intgNo']"/>, since quite often when editing an entity after it was created, some fields must not be editable anymore.
  2. support in <f:field:
    • the proposed correct way by authors would be to use <f:field bean="tableTwo" property="strType" widget-readonly="true"/>
    • users would expected <f:field bean="tableTwo" property="strType" readonly="true"/> however, since readonly is not a custom property to be used with widget-*, but one that the default templates seem to use.
    • even with widget-*, this is still not working always correctly, since the default templates do not implement this right ( #267 might have helped to see rendering bug):
    • see https://github.com/aadrian/fieldbugs1/blob/master/grails-app/views/tableTwo/edit.gsp#L38 : it is still possible to change the value of strType and intgNo despite being readonly like strName (only this one works correctly). Just run the example from https://github.com/aadrian/fieldbugs1 with grails run-app to see this in action.

@sbglasius I don't think this is an enhancement, but more of a bug. The documentation clearly states that all other parameters are passed down, but for f:field at least this is not the case :( .

Please try adding widget-readonly to pass down attributes to the widget rendering. Remember that the fields plugin works by:

<f:field bean="${myBean}" property="myProperty"/>

Approximately does the following:

<render template="_fields/default/wrapper>
   <render template="_fields/default/widget"/>
</render>

and adding widget-* passes the * to the underlying widget.

@jeffbrown please see above my updated clarifications and examples in the ticket description.

Thank you.

Readonly handling is extremely bad with Grails 3 :( . Any chance this being addressed for 3.3.7 ?