Summary
The instance method merge_wrapper_options
is defined on the SimpleForm::Inputs::Base
class, but not until version 3.1.0.rc1.
Here's the relevant source code for version 3.0.2 (no merge_wrapper_options
):
https://github.com/plataformatec/simple_form/blob/v3.0.2/lib/simple_form/inputs/base.rb
Contrast this with version 3.1.0.rc1:
https://github.com/plataformatec/simple_form/blob/v3.1.0.rc1/lib/simple_form/inputs/base.rb
So if you're at v3.0.2 or prior, you won't have it. But, no big deal, just define the method yourself:
Code
/app/inputs/fake_string_input.rb
class FakeStringInput < SimpleForm::Inputs::StringInput
# Creates a basic input without reading any value from object
def input(wrapper_options = nil)
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
template.text_field_tag(attribute_name, nil, merged_input_options)
end # method
def merge_wrapper_options(options, wrapper_options)
if wrapper_options
options.merge(wrapper_options) do |_, oldval, newval|
if Array === oldval
oldval + Array(newval)
end
end
else
options
end
end # method
end # class
/app/views/some_form.html.haml
= f.input :some_parameter,
label: false,
as: :fake_string,
input_html: { value: 'some-value' }
The POST request will contain:
Parameters: {"utf8"=>"✓", "some_parameter"=>"some-value" }
FakeInput
class? – Withstand