Pass all options on input_field method as input_html option
This commit is contained in:
parent
2700b1316c
commit
e02742a719
|
@ -91,7 +91,8 @@ module SimpleForm
|
|||
end
|
||||
alias :attribute :input
|
||||
|
||||
# Creates a input tag for the given attribute.
|
||||
# Creates a input tag for the given attribute. All the given options
|
||||
# are sent as :input_html.
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
|
@ -105,6 +106,7 @@ module SimpleForm
|
|||
# name="user[name]" size="100" type="text" value="Carlos" />
|
||||
#
|
||||
def input_field(attribute_name, options={})
|
||||
options[:input_html] = options.dup
|
||||
options.merge!({:components => [:input], :wrapper => false})
|
||||
input(attribute_name, options)
|
||||
end
|
||||
|
|
|
@ -388,6 +388,22 @@ class FormBuilderTest < ActionView::TestCase
|
|||
assert_no_select '.hint'
|
||||
end
|
||||
|
||||
test 'builder should allow passign options to input tag' do
|
||||
with_concat_form_for(@user) do |f|
|
||||
f.input_field :name, :id => 'name_input', :class => 'name'
|
||||
end
|
||||
|
||||
assert_select 'input.string.name#name_input'
|
||||
end
|
||||
|
||||
test 'builder should generate an input tag with a clean HTML' do
|
||||
with_concat_form_for(@user) do |f|
|
||||
f.input_field :name
|
||||
end
|
||||
|
||||
assert_no_select 'input.string[input_html]'
|
||||
end
|
||||
|
||||
# WITHOUT OBJECT
|
||||
test 'builder should generate properly when object is not present' do
|
||||
with_form_for :project, :name
|
||||
|
|
Loading…
Reference in New Issue