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:
- 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. - 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, sincereadonly
is not a custom property to be used withwidget-*
, 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
andintgNo
despite being readonly likestrName
(only this one works correctly). Just run the example from https://github.com/aadrian/fieldbugs1 withgrails run-app
to see this in action.
- the proposed correct way by authors would be to use
@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.
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.
@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 ?