{"issue":{"state":"open","pull_request":{"diff_url":"https://github.com/rails/rails/pull/3590.diff","html_url":"https://github.com/rails/rails/pull/3590","patch_url":"https://github.com/rails/rails/pull/3590.patch"},"milestone":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/76a777ff80f30bd3b390e275cce625bc?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"76a777ff80f30bd3b390e275cce625bc","url":"https://api.github.com/users/amatsuda","login":"amatsuda","id":11493},"labels":[],"updated_at":"2011-11-10T10:42:04Z","assignee":null,"closed_at":null,"comments":1,"url":"https://api.github.com/repos/rails/rails/issues/3590","body":"This patch was actually written more than a year ago, but unfortunately had lost in somewhere between [Lighthouse](https://rails.lighthouseapp.com/projects/8994/tickets/5120) and GitHub. So let me propose here again...\r\n\r\nHTML5 has a new feature called [Client-side form validation](http://www.w3.org/TR/html5/forms.html#client-side-form-validation) and ActiveModel::Validators lets us easily know what kind of validations are defined on our models.\r\n\r\nSo, I came up with another new feature combining these two technologies.\r\n\r\nNow, when creating a form with a model which has a `validates_presence_of` field,\r\n\r\n```ruby\r\nclass User < ActiveRecord::Base\r\n  validates_presence_of :name\r\nend\r\n```\r\n\r\n```erb\r\n<%= form_for User.new do |f| %>\r\n  <%= f.text_field :name %>\r\n  <%= f.submit %>\r\n<% end %>\r\n```\r\n\r\nthe `required=\"required\"` attribute are automagically injected into the generated input field.\r\n\r\n```html\r\n<input id=\"user_name\" name=\"user[name]\" required=\"required\" size=\"30\" type=\"text\" />\r\n```\r\n\r\nThis enables seamless client-side validation without any extra JavaScript coding.\r\n\r\nI baked this feature into a gem for Rails 3, so please take a look at https://github.com/amatsuda/html5_validators for more documentations, and give it a try to see how it actually works.","html_url":"https://github.com/rails/rails/issues/3590","title":"automatic client side validation with HTML 5 \"required\" attribute","number":3590,"id":2195142,"created_at":"2011-11-10T06:06:43Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/e837f6b7fd146ab16ed3d663476c063e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"e837f6b7fd146ab16ed3d663476c063e","url":"https://api.github.com/users/josevalim","login":"josevalim","id":9582},"updated_at":"2011-11-10T10:42:04Z","url":"https://api.github.com/repos/rails/rails/issues/comments/2693799","body":"Thanks for the pull request but I am a bit skeptical about merging this. Some reasons:\r\n\r\n1) Support between different browsers is still unstable. The behavior changes a lot and you have poor customization.\r\n2) If we are supporting this feature, it needs to be opt-in because it is backwards incompatible. Many integration tests through selenium would fail for example.\r\n3) ActionView::Helpers and ActiveResource are the worst (in terms of legacy) Rails code. I would strongly suggest cleaning up the house before adding more features.\r\n4) I believe those Rails form helpers have always intended to be low level. I am skeptical about adding more features, if we are going down this path, I would suggest creating a new form builder inside Rails that inherits from the base one in order to add HTML5 features. For now, I would move such behavior to plugins (as SimpleForm and Formtastic) as you did.","id":2693799,"created_at":"2011-11-10T10:42:04Z"}}