Module: LotusAdmin::FormHelpers

Defined in:
app/helpers/lotus_admin/form_helpers.rb

Instance Method Summary collapse

Instance Method Details

#material_form_button(label) ⇒ Object



24
25
26
27
28
# File 'app/helpers/lotus_admin/form_helpers.rb', line 24

def material_form_button(label)
  button_tag class: 'btn btn-success' do
    label.html_safe + (:i, nil, class: 'zmdi zmdi-arrow-forward')
  end
end

#material_form_cancel(path) ⇒ Object



20
21
22
# File 'app/helpers/lotus_admin/form_helpers.rb', line 20

def material_form_cancel(path)
  link_to 'Cancel', path, class: 'btn btn-link'
end

#material_form_for(resource, options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'app/helpers/lotus_admin/form_helpers.rb', line 3

def material_form_for(resource, options = {}, &block)
  options[:builder] ||= LotusAdmin::FormBuilder
  options[:wrapper] = :material_form
  options[:wrapper_mappings] = {
    boolean: :material_boolean_horizontal
  }

  simple_form_for(resource, options, &block)
end

#material_form_submit(resource) ⇒ Object



13
14
15
16
17
18
# File 'app/helpers/lotus_admin/form_helpers.rb', line 13

def material_form_submit(resource)
  label = "Create #{ resource.class.model_name.human }"
  label = "Save Changes" if resource.persisted?

  material_form_button(label)
end