Module: EffectiveFormBuilderHelper

Defined in:
app/helpers/effective_form_builder_helper.rb

Instance Method Summary collapse

Instance Method Details

#effective_form_with(**options, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/effective_form_builder_helper.rb', line 2

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 EffectiveBootstrap.validate(this);')

  if options.delete(:remote) == true
    if options[:html][:data].kind_of?(Hash)
      options[:html][:data][:remote] = true
    else
      options[:html]['data-remote'] = true
    end
  end

  without_error_proc do
    form_with(**options.merge(builder: Effective::FormBuilder), &block)
  end
end