Repository navigation
Conversation
The select tag has supported optionDisabled since Grails 2.4, but neither the tag reference nor the @attr Javadoc of the tag listed it. Document the attribute, including two limits of its current behavior: it is only used together with optionKey, and the option of the current value is never disabled, because a browser does not submit a disabled option. Add tests for the property name and closure forms and for both limits.
jamesfredley
left a comment
Contributor
There was a problem hiding this comment.
Requested changes. The note leaves out that a keys list turns optionDisabled off.
| * `value` (optional) - The current selected value that evaluates equals() to `true` for one of the elements in the `from` list. | ||
| * `optionKey` (optional) - By default, the `value` attribute of each `<option>` element will be the result of a `toString()` call on each element. Setting this allows the value to be a bean property of each element in the list. | ||
| * `optionValue` (optional) - By default, the body of each `<option>` element will be the result of a `toString()` call on each element in the `from` attribute list. Setting this allows the value to be a bean property of each element in the list. | ||
| * `optionDisabled` (optional) - Disables some of the `<option>` elements. Either the name of a bean property of each element in the `from` list, or a Closure that accepts an element, such as `optionDisabled="${{ it.stock == 0 }}"`. The `<option>` element is disabled when the result is `true` (Groovy truth). Only used together with `optionKey`. The `<option>` element of the current `value` is never disabled, because a browser does not submit a disabled option. |
Contributor
There was a problem hiding this comment.
The example uses optionDisabled and optionKey. Adding a keys list makes the second book selectable even though it is out of print, because keys skips optionDisabled. Say to leave keys out when using optionDisabled.
sbglasius
reviewed
Nov 25, 2026
sbglasius
left a comment
Contributor
There was a problem hiding this comment.
This is an AI assisted review
Docs and tests match FormTagLib. Agree with @jamesfredley: keys takes precedence over optionKey, so optionDisabled is ignored when keys is set. Please add "and without keys" to the "Only used together with optionKey" sentence in both select.adoc and the @attr Javadoc. LGTM otherwise.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
<g:select>has supportedoptionDisabledsince Grails 2.4 (GRAILS-8494), but the attribute was never added to the tag reference or to the@attrJavadoc of the tag. Someone noticed this on the users mailing list.optionDisabledto the reference page, with an example, and to the@attrlist inFormTagLib.optionKey, and the option of the currentvalueis never disabled, because a browser does not submit a disabled option.This changes no behavior.