Only add required if browser_validations is enabled.
This commit is contained in:
parent
2d41fafe9b
commit
d245019220
|
@ -16,7 +16,10 @@ module SimpleForm
|
|||
end
|
||||
|
||||
def has_required?
|
||||
required_field?
|
||||
# We need to check browser_validations because
|
||||
# some browsers are still checking required even
|
||||
# if novalidate was given.
|
||||
required_field? && SimpleForm.browser_validations
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -249,6 +249,14 @@ class CollectionInputTest < ActionView::TestCase
|
|||
assert_select 'select[required]'
|
||||
end
|
||||
|
||||
test 'when not using browser validations, input should not generate required html attribute' do
|
||||
swap SimpleForm, :browser_validations => false do
|
||||
with_input_for @user, :name, :string
|
||||
assert_select 'input[type=text].required'
|
||||
assert_no_select 'input[type=text][required]'
|
||||
end
|
||||
end
|
||||
|
||||
test 'collection input with select type should not generate required html attribute without blank option' do
|
||||
with_input_for @user, :name, :select, :include_blank => false, :collection => ['Jose' , 'Carlos']
|
||||
assert_select 'select.required'
|
||||
|
|
Loading…
Reference in New Issue