Do not emit `prompt` as an HTML attribute when using `input_field`.

This commit is contained in:
Lucas Mazza 2016-08-09 11:33:29 -03:00
parent 8a4b9eb948
commit e62018afa8
No known key found for this signature in database
GPG Key ID: C009F9A6BE4A44CB
2 changed files with 7 additions and 1 deletions

View File

@ -140,7 +140,7 @@ module SimpleForm
components = (wrapper.components.map(&:namespace) & ATTRIBUTE_COMPONENTS)
options = options.dup
options[:input_html] = options.except(:as, :boolean_style, :collection, :label_method, :value_method, *components)
options[:input_html] = options.except(:as, :boolean_style, :collection, :label_method, :value_method, :prompt, *components)
options = @defaults.deep_dup.deep_merge(options) if @defaults
input = find_input(attribute_name, options)

View File

@ -121,6 +121,12 @@ class InputFieldTest < ActionView::TestCase
assert_no_select 'input.boolean[boolean_style]'
end
test 'build input_field does not treat "prompt" as a HTML attribute' do
with_input_field_for @user, :attempts, collection: [1,2,3,4,5], prompt: :translate
assert_no_select 'select[prompt]'
end
test 'build input_field without pattern component use the pattern string' do
swap_wrapper :default, custom_wrapper_with_html5_components do
with_input_field_for @user, :name, pattern: '\w+'