mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Ensure that only textarea has a placeholder
This commit is contained in:
parent
700985cb0f
commit
fdecf95988
2 changed files with 10 additions and 1 deletions
|
@ -14,7 +14,7 @@ module SimpleForm
|
|||
|
||||
def input_html_options
|
||||
input_options = super
|
||||
input_options[:placeholder] ||= placeholder if has_placeholder?
|
||||
input_options[:placeholder] ||= placeholder if has_placeholder? and text?
|
||||
input_options
|
||||
end
|
||||
|
||||
|
@ -24,6 +24,10 @@ module SimpleForm
|
|||
self.class.mappings[input_type] or
|
||||
raise("Could not find method for #{input_type.inspect}")
|
||||
end
|
||||
|
||||
def text?
|
||||
input_type == :text
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -209,6 +209,11 @@ class InputTest < ActionView::TestCase
|
|||
assert_select 'input#user_name[type=file]'
|
||||
end
|
||||
|
||||
test "input should generate a file field that don't accept placeholder" do
|
||||
with_input_for @user, :name, :file, :placeholder => 'Put in some text'
|
||||
assert_no_select 'input[placeholder]'
|
||||
end
|
||||
|
||||
test 'mapping input should generate an error if type is not found' do
|
||||
with_concat_form_for(@user) do |f|
|
||||
assert_raise(RuntimeError, "Could not find method for nil") do
|
||||
|
|
Loading…
Reference in a new issue