support form html5's required attribute #112

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants
@sarmbruster
Member

sarmbruster commented Oct 3, 2011

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

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
@jeffbrown

This comment has been minimized.

Show comment
Hide comment
@jeffbrown

jeffbrown Oct 3, 2011

Member

Stefan,

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

Thanks for the help.

Member

jeffbrown commented Oct 3, 2011

Stefan,

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

Thanks for the help.

@sarmbruster

This comment has been minimized.

Show comment
Hide comment
@robfletcher

This comment has been minimized.

Show comment
Hide comment
@robfletcher

robfletcher Oct 3, 2011

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.

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

This comment has been minimized.

Show comment
Hide comment
@denisfalqueto

denisfalqueto Jan 27, 2012

Contributor

@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.

Contributor

denisfalqueto commented Jan 27, 2012

@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

This comment has been minimized.

Show comment
Hide comment
@lhotari

lhotari Aug 8, 2014

Member

Closing outdated pull requests.

Member

lhotari commented Aug 8, 2014

Closing outdated pull requests.

@lhotari lhotari closed this Aug 8, 2014

tcrossland added a commit to tcrossland/grails-core that referenced this pull request Feb 2, 2016

tcrossland added a commit to tcrossland/grails-core that referenced this pull request Feb 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment