I try to config simple_form to always set all fields NOT required by default.
But I still need this when I put :required => true
in the view.
Then I go to config/initializers/simple_form.rb
and set it like this.
config.wrappers :default, :class => :input, :required => false,
:hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
and set config.required_by_default = false
But asterisk still show up.
Thanks for any suggestion.
It's also possible to change SimpleForm setup.
SimpleForm.setup do |config|
# Whether attributes are required by default (or not). Default is true.
config.required_by_default = false
end
Take this into account: (taken from simple form github page)
Required fields are marked with an * prepended to their labels.
By default all inputs are required. When the form object includes ActiveModel::Validations (which, for example, happens with Active Record models), fields are required only when there is presence validation. Otherwise, Simple Form will mark fields as optional. For performance reasons, this detection is skipped on validations that make use of conditional options, such as :if and :unless.