Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffolding does not respect display: and editable: fields #62

Open
xpusostomos opened this issue Dec 4, 2021 · 4 comments
Open

Scaffolding does not respect display: and editable: fields #62

xpusostomos opened this issue Dec 4, 2021 · 4 comments

Comments

@xpusostomos
Copy link

According to the documentation:

http://docs.grails.org/latest/ref/Constraints/Usage.html

a display: constraint should control whether a property is displayed in scaffolding views.
a editable: constraint should control whether a property can be edited in scaffolding views

When using the default show.gsp scaffolded view,
FormFieldsTagLib line 552 calls domainModelService.getInputProperties(Impl)

This doesn't seem right it calls getINPUTproperties for a show.gsp. Surely a show.gsp should be getOutputProperties?

getInputProperties hard codes the exclusion of dateCreated, lastUpdated and version. Because it is hard coded it doesn't respect your decision to set display: true on those properties. Thus they are not displayed even when display: true is set.

when using the edit.gsp, it also calls the same method, getInputProperties. If I have a field that I do NOT want editable there, I should be able to set editable: false constraint.

However if we look at DomainModelServiceImpl.getInputProperies, it calls getProperties and there it never checks the editable: constraint. It does appear to to check constrained.display... but surely that is the OUTPUT constraint, not the input constraint. It doesn't seem like anywhere in the code it checks the editable constraint.

Task List

Steps to Reproduce

Create a domain object with a few fields, the standard lastUpdated field.
add "display: true" constraint to lastUpdated.
add "editable: false" to some other field.
Generate the standard scaffolding with edit.gsp, show.jsp

Observe that it doesn't respect display: true for lastUpdated
Observe that it doesn't respect editable: false for some other field.

Expected Behaviour

Scaffolded view should respect display: and editable: constraints like the documentation says.

Actual Behaviour

they don't.

Environment Information

  • Grails Version: 4.0.11
  • JDK Version: 1.8
@jeffscottbrown
Copy link
Member

When using the default show.gsp scaffolded view,
FormFieldsTagLib line 552 calls domainModelService.getInputProperties(Impl)

This doesn't seem right it calls getINPUTproperties for a show.gsp. Surely a show.gsp should be getOutputProperties?

I don't think so. I think getOutputProperties is supposed to return a list of properties that are to be visible and getInputProperties is supposed to return a list of properties that allow for user input. For show.gsp, I think it makes sense to retrieve the list of properties that are to be visible.

@xpusostomos
Copy link
Author

I agree that it makes sense that for show.gsp, it shoudl retrieve the list of properties that are to be visible... so why does show.gsp end up calling getInputProperties, rather than getOutputProperties? and why does getInputProperties check the 'display' property rather than the 'editable' property?

@jeffscottbrown
Copy link
Member

so why does show.gsp end up calling getInputProperties, rather than getOutputProperties?

I don't know the answer to that. I misread the comment and thought you were suggesting the opposite of what you did. That was my mistake.

@jeffscottbrown jeffscottbrown transferred this issue from grails/grails-core Feb 8, 2022
@A586788
Copy link

A586788 commented Sep 13, 2022

@xpusostomos did you found a solution? i have the same problem...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants