Module: PhantomForms::Helper
- Defined in:
- lib/phantom_forms/helper.rb
Instance Method Summary collapse
- #buttons_for(object, options = {}) ⇒ Object
- #modal_buttons_for(object, options = {}) ⇒ Object
- #modal_form_for(object, options = {}, &block) ⇒ Object
- #normal_form_for(object, options = {}, &block) ⇒ Object
- #normal_modal_form_for(object, options = {}, &block) ⇒ Object
- #remote_form_for(object, options = {}, &block) ⇒ Object
- #remote_form_panel_for(object, panel_title = nil, options = {}, &block) ⇒ Object
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 (object, = {}) object_name = get_class(object) object_class = [:nested_id] || object_name locale_name = object_name.underscore locale = [:label] || t("#{locale_name}.save") content_tag :div, :class => 'row' do [ content_tag(:div, :class => 'col-md-9') do concat ( locale , :id => "submit-#{object_class}-button") end, content_tag(:div, :class => 'col-md-3') do concat link_to_cancel( :id => "cancel-#{object_class}-link") end ].join.html_safe end end |
#modal_buttons_for(object, options = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/phantom_forms/helper.rb', line 84 def (object, = {}) object_name = get_class(object) object_class = [:nested_id] || object_name locale_name = object_name.underscore locale = [:label] || t("#{locale_name}.save") content_tag :div, :class => 'row' do content_tag :div, :class => 'col-md-12' do concat ( locale , :id => "submit-#{object_class}-button") concat link_to_modal_cancel( :id => "cancel-#{object_class}-link") end end end |
#modal_form_for(object, options = {}, &block) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/phantom_forms/helper.rb', line 50 def modal_form_for(object, = {}, &block) [:validate] = true [:builder] = PhantomForms::FormBuilders::ValidateFormBuilder [:html] = {:'data-type' => 'script', :class => 'remote-form'} [:remote] = true form_for(object, , &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, = {}, &block) [:validate] = true [:builder] = PhantomForms::FormBuilders::ValidateFormBuilder [:html] = {:class => 'normal-form form'} content_tag :div, class: "row" do content_tag :div, class: "col-md-12" do form_for(object, , &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, = {}, &block) [:validate] = true [:builder] = PhantomForms::FormBuilders::ValidateFormBuilder [:html] = {:'data-type' => 'script', :class => 'normal-form'} form_for(object, , &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, = {}, &block) [:validate] = true [:builder] = PhantomForms::FormBuilders::ValidateFormBuilder [:remote] = true [:html] = {:class => 'remote-form form'} content_tag :div, class: "col-md-12" do content_tag :div, class: "well" do form_for(object, , &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, = {}, &block) [:validate] = true [:builder] = PhantomForms::FormBuilders::ValidateFormBuilder [:remote] = true [:html] = {:class => 'remote-form form'} content_tag :div, class: "col-md-12" do content_tag :div, class: "panel panel-primary" do [ if panel_title content_tag :div, class: "panel-heading" do content_tag :h3, class: "panel-title" do panel_title end end end, content_tag(:div, class: "panel-body") do form_for(object, , &block) end ].join.html_safe end end end |