1
0
Fork 0
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:
Rafael Mendonça França 2010-10-07 03:54:43 +08:00 committed by Carlos Antonio da Silva
parent 700985cb0f
commit fdecf95988
2 changed files with 10 additions and 1 deletions

View file

@ -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

View file

@ -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