fields icon indicating copy to clipboard operation
fields copied to clipboard

Missing of 'readonly' attribute configurabiltiy!

Open aadrian opened this issue 6 years ago • 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.

aadrian avatar Mar 08 '18 11:03 aadrian

@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 :( .

aadrian avatar Mar 13 '18 09:03 aadrian

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.

sbglasius avatar Mar 13 '18 09:03 sbglasius

I can't reproduce this. The code at https://github.com/jeffbrown/issue259/blob/e1cc0cfb436b230060febd6fb5bd0ec239430b1f/grails-app/views/person/show.gsp#L18-L19 appears to work as designed.

osscontributor avatar Mar 20 '18 01:03 osscontributor

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

Thank you.

aadrian avatar Mar 20 '18 10:03 aadrian

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

eprozium avatar Aug 08 '18 08:08 eprozium