Method: EffectiveResourcesHelper#simple_form_submit

Defined in:
app/helpers/effective_resources_helper.rb

#simple_form_submit(form, options = {}, &block) ⇒ Object

effective_form_inputs



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/effective_resources_helper.rb', line 18

def simple_form_submit(form, options = {}, &block)
  actions = controller.try(:submits) || raise('controller must be an Effective::CrudController')
  actions = permitted_resource_actions(form.object, actions)

  submits = actions.map { |name, opts| form.button(:submit, name, opts.except(:action, :title, 'data-method')) }

  # I think this is a bug. I can't override default button class when passing my own class: variable. it merges them.
  if (btn_class = SimpleForm.button_class).present?
    submits = submits.map { |submit| submit.sub(btn_class, '') }
  end

  submits = submits.join(' ').html_safe

  wrapper_options = { class: 'form-actions' }.merge(options.delete(:wrapper_html) || {})

  (:div, wrapper_options) do
    (block_given? ? capture(&block) : ''.html_safe) + submits
  end
end