{"id":1529,"date":"2010-12-08T17:49:22","date_gmt":"2010-12-08T19:49:22","guid":{"rendered":"http:\/\/blog.plataformatec.com.br\/?p=1529"},"modified":"2010-12-08T17:49:22","modified_gmt":"2010-12-08T19:49:22","slug":"simpleform-1-3-more-html-5-goodness-and-new-stuff","status":"publish","type":"post","link":"https:\/\/blog.plataformatec.com.br\/2010\/12\/simpleform-1-3-more-html-5-goodness-and-new-stuff\/","title":{"rendered":"SimpleForm 1.3: more HTML 5 goodness and new stuff"},"content":{"rendered":"

We have been working on SimpleForm for some time since the last release and have got a lot of contributions from community. Now it is time for a new release with more HTML 5 compatibility plus some new cool features. So, without further ado, lets take a ride on the new stuff.<\/p>\n

HTML 5<\/h3>\n

One of the most useful features coming in HTML 5, in my opinion, is the placeholder option. This option allows us to configure a text to be shown inside the input when it is empty. This is really nice to help the user while filling out forms. SimpleForm now gives us the possibility to pass in a placeholder option in the same way we are used to do with use hints:<\/p>\n

\r\n<%= simple_form_for @user do |f| %>\r\n  <%= f.input :username, :label => 'Your username please' %>\r\n  <%= f.input :password, :hint => 'No special characters.' %>\r\n  <%= f.input :email, :placeholder => 'user@domain.com' %>\r\n  <%= f.button :submit %>\r\n<% end %>\r\n<\/pre>\n

As you can see here, the placeholder is given as String, but it can also be fetched from I18n, as labels\/hints does.<\/p>\n

Another addition is the automatic lookup of min\/max values from numericality validations, for number<\/code> inputs. For instance:<\/p>\n

\r\nclass User\r\n  validates_numericality_of :age, :greater_than_or_equal_to => 18,\r\n    :less_than_or_equal_to => 99, :only_integer => true\r\nend\r\n<\/pre>\n
\r\n<%= simple_form_for @user do |f| %>\r\n  <%= f.input :age %>\r\n<% end %>\r\n<\/pre>\n

Would generate an input with type number, and the min\/max attributes configured with 18 and 99, respectively.<\/p>\n

Besides that SimpleForm also adds:<\/p>\n