Closed klondikemarlen closed 2 months ago
Hey @klondikemarlen! There's exactly what you want in README:
You can also redefine existing Simple Form inputs by creating a new class with the same name. For instance, if you want to wrap date/time/datetime in a div, you can do:
# app/inputs/date_time_input.rb class DateTimeInput < SimpleForm::Inputs::DateTimeInput def input(wrapper_options) template.content_tag(:div, super) end end
So this would be?
# app/inputs/search.rb
class Search < SimpleForm::Inputs::StringInput
def input(wrapper_options)
# custom input code?
end
end
Honestly its been so long, I don't even remember the problem I was trying to solve. I'm using Vue for front-end work now.
@klondikemarlen yeah, something like that
Precheck
Environment
Current behavior
If I want to customize the search input, e.g.
f.input(:search, as: :search)
, I can't do so in a comfortable way. I can dof.input(:search, as: :custom_search)
and build aCustomSearchInput < SimpleForm::Inputs::StringInput
, but this doesn't feel very natural. I can also doSimpleForm::FormBuilder.mappings[:search] = CustomSearchInput
, but this doesn't use a public interface.Expected behavior
To be able to tweak the default
SimpleForm::FormBuilder.mappings[:search]
via a config option. e.g.