Sha256: d7b76d40456dc992ddbf3a262449bd79141437a15ff940143fcf6d3665a2bcd8
Contents?: true
Size: 1.12 KB
Versions: 5
Compression:
Stored size: 1.12 KB
Contents
module EffectiveFormBuilderHelper def effective_form_with(**options, &block) options[:class] = [options[:class], 'needs-validation', ('form-inline' if options[:layout] == :inline)].compact.join(' ') options[:html] = (options[:html] || {}).merge(novalidate: true, onsubmit: 'return EffectiveForm.validate(this);') if options.delete(:remote) == true @_effective_remote_index ||= 0 if options[:html][:data].kind_of?(Hash) options[:html][:data][:remote] = true options[:html][:data]['data-remote-index'] = (@_effective_remote_index += 1) else options[:html]['data-remote'] = true options[:html]['data-remote-index'] = (@_effective_remote_index += 1) end end without_error_proc do form_with(**options.merge(builder: Effective::FormBuilder), &block) end end private # Disables a .fields_with_errors wrapping div when def without_error_proc original = ActionView::Base.field_error_proc begin ActionView::Base.field_error_proc = proc { |input, _| input }; yield ensure ActionView::Base.field_error_proc = original end end end
Version data entries
5 entries across 5 versions & 1 rubygems