apache / apache/grails-core

Scaffolding does not respect display: and editable: fields

Open
#14,270 4 comments 0 reactions 0 assignees View on GitHub
relates-to: scaffolding
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

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

Contributor guide

Open the contributing guide

Research direction

Start at FormFieldsTagLib line 552 and trace the getInputProperties call for show.gsp, then inspect DomainModelServiceImpl.getInputProperties and getProperties for constraint handling. Reproduce with a domain object containing lastUpdated, display: true, and editable: false, and verify generated show.gsp and edit.gsp honor both constraints.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.