and added some documentation for the form specfic novalidate feature.
This commit is contained in:
Kai Schlamp 2011-06-03 20:17:04 +02:00
parent 9bd9e9821b
commit cd105e312b
3 changed files with 10 additions and 1 deletions

View File

@ -442,6 +442,10 @@ If you want to have all other HTML 5 features, such as the new field types, you
This option adds a new `novalidate` property to the form, instructing it to skip all HTML 5 validation. The inputs will still be generated with the required and other attributes, that might help you to use some generic javascript validation.
You can also add `novalidate` to a specific form by setting the option on the form itself:
<%= simple_form_for(resource, :html => {:novalidate => true}) do |form| %>
Please notice that any of the configurations above will disable the `placeholder` component, which is an HTML 5 feature. We believe most of the newest browsers are handling this attribute fine, and if they aren't, any plugin you use would take of using the placeholder attribute to do it. However, you can disable it if you want, by removing the placeholder component from the components list in SimpleForm configuration file.
== Configuration

View File

@ -40,7 +40,7 @@ module SimpleForm
else dom_class(record_or_name_or_array)
end
options[:html] ||= {}
options[:html][:novalidate] = !SimpleForm.browser_validations
options[:html][:novalidate] ||= !SimpleForm.browser_validations
options[:html][:class] = "\#{SimpleForm.form_class} \#{css_class} \#{options[:html][:class]}".strip
with_custom_field_error_proc do

View File

@ -25,6 +25,11 @@ class FormHelperTest < ActionView::TestCase
end
end
test 'simple form should use the form specific validation option if specified on the form itself' do
concat(simple_form_for(:user, :html => {:novalidate => true}) do |f| end)
assert_select 'form[novalidate="novalidate"]'
end
test 'simple form should add object name as css class to form when object is not present' do
concat(simple_form_for(:user) do |f| end)
assert_select 'form.simple_form.user'