Module: UsefulHelpers::Helpers::FormtasticHelper

Defined in:
lib/useful_helpers/helpers/formtastic_helper.rb

Instance Method Summary collapse

Instance Method Details

#actions_for(form, label = nil) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/useful_helpers/helpers/formtastic_helper.rb', line 25

def actions_for(form, label=nil)
  print_label = label ? label : nil
  html = ""
  html += form.actions do
    submit_for(form, print_label) + cancel_for(form)
  end
  raw html
end

#cancel_for(form, label = nil) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/useful_helpers/helpers/formtastic_helper.rb', line 42

def cancel_for(form, label=nil)
  print_label = label ? label : "Отмена"
  form.action :cancel,
              :as => :link,
              :label => print_label,
              :button_html => {:class => "a_button cancelite"}
end

#formtastic_cancel_button(object, redirect_path = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/useful_helpers/helpers/formtastic_helper.rb', line 5

def formtastic_cancel_button(object, redirect_path=nil)
  path =
  if redirect_path
    redirect_path
  else
    if object.new_record?
      collection_path
    else
      resource_path(object)
    end
  end
   :li,
      link_to(
        t("web-app-theme.cancel"),
        path,
        :class => "cancel"
      ),
      :class => "commit_button"
end

#submit_for(form, label = nil) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/useful_helpers/helpers/formtastic_helper.rb', line 34

def submit_for(form, label=nil)
  print_label = label ? label : "Отправить"
  form.action :submit,
              :as => :button,
              :label => raw("<span class='b-btn__wrap g-dib'>#{print_label}</span>"),
              :button_html => {:class => "b-btn _blue g-dib"}
end