Module: PhantomForms::Helper

Defined in:
lib/phantom_forms/helper.rb

Instance Method Summary collapse

Instance Method Details

#buttons_for(object, options = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/phantom_forms/helper.rb', line 65

def buttons_for(object, options = {})
  object_name = get_class(object)
  object_class = options[:nested_id] ||  object_name

  locale_name =  object_name.underscore
  locale = options[:label] || t("#{locale_name}.save")

   :div, :class => 'row' do
    [
      (:div, :class => 'col-md-9') do
        concat submit_button( locale , :id => "submit-#{object_class}-button")
      end,
      (:div, :class => 'col-md-3') do
        concat link_to_cancel( :id => "cancel-#{object_class}-link")
      end
    ].join.html_safe
  end
end


84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/phantom_forms/helper.rb', line 84

def modal_buttons_for(object, options = {})
  object_name = get_class(object)
  object_class = options[:nested_id] ||  object_name

  locale_name =  object_name.underscore
  locale = options[:label] || t("#{locale_name}.save")

   :div, :class => 'row' do
     :div, :class => 'col-md-12' do
      concat submit_button( locale , :id => "submit-#{object_class}-button")
      concat link_to_modal_cancel( :id => "cancel-#{object_class}-link")
    end
  end
end


50
51
52
53
54
55
56
# File 'lib/phantom_forms/helper.rb', line 50

def modal_form_for(object, options = {}, &block)
  options[:validate] = true
  options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
  options[:html] = {:'data-type' => 'script', :class => 'remote-form'}
  options[:remote] = true
  form_for(object, options, &block)
end

#normal_form_for(object, options = {}, &block) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/phantom_forms/helper.rb', line 39

def normal_form_for(object, options = {}, &block)
  options[:validate] = true
  options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
  options[:html] = {:class => 'normal-form form'}
   :div, class: "row" do
     :div, class: "col-md-12" do
      form_for(object, options, &block)
    end
  end
end

#normal_modal_form_for(object, options = {}, &block) ⇒ Object



58
59
60
61
62
63
# File 'lib/phantom_forms/helper.rb', line 58

def normal_modal_form_for(object, options = {}, &block)
  options[:validate] = true
  options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
  options[:html] = {:'data-type' => 'script', :class => 'normal-form'}
  form_for(object, options, &block)
end

#remote_form_for(object, options = {}, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/phantom_forms/helper.rb', line 4

def remote_form_for(object, options = {}, &block)
  options[:validate] = true
  options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
  options[:remote] = true
  options[:html] = {:class => 'remote-form form'}
   :div, class: "col-md-12" do
     :div, class: "well" do
      form_for(object, options, &block)
    end
  end
end

#remote_form_panel_for(object, panel_title = nil, options = {}, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/phantom_forms/helper.rb', line 16

def remote_form_panel_for(object, panel_title = nil, options = {}, &block)
  options[:validate] = true
  options[:builder] = PhantomForms::FormBuilders::ValidateFormBuilder
  options[:remote] = true
  options[:html] = {:class => 'remote-form form'}
   :div, class: "col-md-12" do
     :div, class: "panel panel-primary" do
      [
        if panel_title
           :div, class: "panel-heading" do
             :h3, class: "panel-title" do
              panel_title
            end
          end
        end,
        (:div, class: "panel-body") do
          form_for(object, options, &block)
        end
      ].join.html_safe
    end
  end
end