You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: grails-doc/src/en/ref/Constraints.adoc
+50-1Lines changed: 50 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -176,13 +176,62 @@ Some constraints have no impact on persistence but customize the scaffolding. It
176
176
|===
177
177
|Constraint|Description
178
178
179
-
|display|Boolean that determines whether the property is displayed in the scaffolding views. If `true` (the default), the property _is_ displayed.
179
+
|display|Controls whether and where the property is displayed in scaffolding views. Accepts a boolean or a `DisplayType` enum value (see below).
180
180
|editable|Boolean that determines whether the property can be edited from the scaffolding views. If `false`, the associated form fields are displayed in read-only mode.
181
181
|format|Specify a display format for types that accept one, such as dates. For example, 'yyyy-MM-dd'.
182
182
|password|Boolean indicating whether this is property should be displayed with a password field. Only works on fields that would normally be displayed with a text field.
183
183
|widget|Controls what widget is used to display the property. For example, 'textarea' will force the scaffolding to use a <textArea> tag.
184
184
|===
185
185
186
+
==== The display Constraint
187
+
188
+
The `display` constraint controls whether a property appears in scaffolded views. It accepts either a boolean value or a `DisplayType` enum value for fine-grained control.
189
+
190
+
===== Boolean Values (Backwards Compatible)
191
+
192
+
[source,groovy]
193
+
----
194
+
static constraints = {
195
+
internalNotes display: false // Never show this property
196
+
title display: true // Show this property (default behavior)
197
+
}
198
+
----
199
+
200
+
===== DisplayType Enum Values
201
+
202
+
For more control over where properties are displayed, use the `DisplayType` enum:
dateCreated display: ALL // Override blacklist, show in all views
217
+
lastUpdated display: OUTPUT_ONLY // Show only in show/index views
218
+
isbn display: INPUT_ONLY // Show only in create/edit forms
219
+
internalNotes display: NONE // Never show
220
+
}
221
+
}
222
+
----
223
+
224
+
|===
225
+
|DisplayType Value|Description
226
+
227
+
|`ALL`|Display the property in all views (input and output). This also overrides the default blacklist for properties like `dateCreated` and `lastUpdated`.
228
+
|`NONE`|Never display the property in any view. Equivalent to `display: false`.
229
+
|`INPUT_ONLY`|Display the property only in input views (create and edit forms).
230
+
|`OUTPUT_ONLY`|Display the property only in output views (show and index/list views).
231
+
|===
232
+
233
+
NOTE: Properties like `version`, `dateCreated`, and `lastUpdated` are excluded from input forms by default. Using `display: ALL` or `display: INPUT_ONLY` on these properties will override this blacklist and include them in input forms.
0 commit comments