support form html5's required attribute #112

Closed
wants to merge 1 commit into
from

Projects

None yet

5 participants

@sarmbruster
grails member

html5 supports usage of a 'required' attribute to indicate mandatory fields.
Previously it was odd behaviour because in fact creates a mandatory field,
because the browser does not look at the value of required attribute, it just uses it's existence.
Now the required attribute is only rendered, of the value of attrs.requires evaluates to true

@sarmbruster sarmbruster support form html5's required attribute
html5 supports usage of a 'required' attribute to indicate mandatory fields.
Previously it was odd behaviour because <g:textField ... required="false"/> in fact creates a mandatory field,
because the browser does not look at the value of required attribute, it just uses it's existence.
Now the required attribute is only rendered, of the value of attrs.requires evaluates to true
484a933
@jeffbrown
grails member

Stefan,

Would you mind creating a JIRA describing the issue related to this commit?

Thanks for the help.

@robfletcher

The same behaviour is true of all boolean attributes in HTML5. e.g. readonly, disabled, multiple, etc. Using false as a value for any such attribute is misleading as the presence of the attribute indicates true. Boolean attributes should really be handled one of 3 ways:

  • A simple SGML-style attribute, i.e. with no ="value". This would be incompatible with any code that handles markup as XML compliant, probably including Groovy's MarkupBuilder.
  • XHTML-style where the value is the name of the property, e.g. `readonly="readonly". I personally find this really ugly but it is valid and arguably the least confusing option.
  • Using the empty string as a value, e.g. readonly="". This remains XML compliant and is less unnecessarily verbose than repeating the attribute name however, I know some people have found it confusing.
@denisfalqueto

@robfletcher I disagree. Those attributes are really dumbly defined (for God's sake, why not just put a true/false or yes/no on the specs?), but we could (and should) do the right thing in Grails. Let's use that as a true boolean value, which is the real purpose for that kind of attribute.

I've done a similar pull request for that kind of behavior just now: #159 (and its backport for 2.0.x: #160). You can see that the result is very usefull.

@lhotari
grails member

Closing outdated pull requests.

@lhotari lhotari closed this Aug 8, 2014
@tcrossland tcrossland added a commit to tcrossland/grails-core that referenced this pull request Feb 2, 2016
@tcrossland tcrossland Support for HTML5 required boolean attribute a800761
@tcrossland tcrossland added a commit to tcrossland/grails-core that referenced this pull request Feb 2, 2016
@tcrossland tcrossland Support for HTML5 required boolean attribute
See also #112
5fb6b57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment