f:field should be enhanced to treat required specially
xpusostomos opened this issue · 1 comments
xpusostomos commented
FormTagLib.groovy, line 64 looks like this....
private List<String> booleanAttributes = ['disabled', 'checked', 'readonly']
However, this is missing the HTML "required" attribute, which is also boolean.
That means you have to work around this in GSP by doing this...
<g:if test="${isRequired}">
<g:field name="foo" required>
</g:if>
<g:else>
<g:field name="foo">
</g:else>
Which is a pain in the ass
One might think this might work:
<g:field name="${property}" ${required?'required':''}/>
However the templating doesn't seem to like that.
`
Task List
FormTagLib.groovy, line 64 should be changed to...
private List<String> booleanAttributes = ['disabled', 'checked', 'readonly', 'required']
Steps to Reproduce
<g:field name="foo" required="${false}">
should expands to this:
<input name="foo">
with no required attribute.
Actual Behaviour
It expands to:
<input name="foo" required="false">
which browsers interpret to mean required is true.
davydotcom commented
merged will be in next grails-gap release