Materialize pushes Rails' checkboxes off-screen, sets them to invisible, and provides its own (label::before
).
When validations fail on a form, Rails' wrapper class field_with_errors
removes the checkboxes provided by Materialize.
In order to maintain Materialize's checkboxes, a (temporary) solution is to add the following to Rails, which removes the field_with_errors
wrapper:
#config/initializers/environment.rb
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
html_tag
end
A more long-term solution would be to edit the above code such that the wrapper class does NOT apply to checkboxes. A Capybara test to #check for the presence of the Materialize checkbox before and after failing would be helpful. Currently, however, when field_with_errors
is active, the following passes when it shouldn't:
#after failing validation
it "keeps the checkboxes active" do
expect(page).to have_unchecked_field(id, visible: true)
end