Unfortunately simple_form relies on using a model. Essentially it would be nice to have something like simple_form_tag and input_tag methods equivalent to their rails *_tag helpers. Until then, there's an easy work around.
Use a symbol instead of the class in the form and pass the value explicitly to prevent simple_form from trying to access the model properties.
All of the methods above still leave you with form data nested inside of "user" or whatever symbol that you pass as the first argument. That's annoying.
To mimic simple_form's style/benefits, but remove the object/symbol dependency and the forced data nesting, you can create a partial.
In the case that you want to add a field that is not part of your model in your form, so that you don't want to read attributes, simple_form propose to use what they call a fake input in their wiki.
String Input
app/inputs/fake_input.rb:
class FakeInput < SimpleForm::Inputs::StringInput
# This method only create 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
end
Then you can do <%= f.input :thing, as: :fake %>
Boolean Input
app/inputs/fake_checkbox_input.rb:
class FakeCheckboxInput < SimpleForm::Inputs::StringInput
# This method only create 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)
tag_name = "#{@builder.object_name}[#{attribute_name}]"
template.check_box_tag(tag_name, options['value'] || 1, options['checked'], merged_input_options)
end
end
Then you can do <%= form.input :remove_avatar, as: :fake_checkbox, wrapper: :vertical_boolean %>