Module: PhantomForms::Helper
- Defined in:
- lib/phantom_forms/helper.rb
Instance Method Summary collapse
- #buttons_for(object, options = {}) ⇒ Object
- #get_class(object) ⇒ Object
- #modal_form_error(id) ⇒ 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
Instance Method Details
#buttons_for(object, options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/phantom_forms/helper.rb', line 68 def (object, = {}) object_name = get_class(object) object_class = [:resource] || object_name locale_name = object_name.underscore locale = [:label] || t("#{locale_name}.save") content_tag :div, class: 'row' do content_tag :div, class: 'col-xs-12' do (locale, :id => "submit-#{object_class}-button") end end end |
#get_class(object) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/phantom_forms/helper.rb', line 85 def get_class(object) object_class_name = object.class.to_s.underscore.dasherize.split('/').last if object_class_name.include? '-decorator' object_class_name.split('-decorator').first else object_class_name end end |
#modal_form_error(id) ⇒ Object
81 82 83 |
# File 'lib/phantom_forms/helper.rb', line 81 def modal_form_error(id) content_tag :div, nil, :id => id end |
#modal_form_for(object, options = {}, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/phantom_forms/helper.rb', line 35 def modal_form_for(object, = {}, &block) [:validate] = true [:builder] = PhantomForms::FormBuilders::ValidateFormBuilder [:html] = {:'data-type' => 'script', :class => 'remote-form'} [:remote] = true object_name = get_class(extract_object(object)) object_class = [:resource] || object_name label = [:label] || t("#{object_name.underscore}.singular") content_tag :div, class: "col-md-12 alert-dismissable" do content_tag :div, class: "panel panel-primary" do concat(panel_title(label, )) concat(content_tag(:div, class: "panel-body") { form_for(object, , &block) }) end end end |
#normal_form_for(object, options = {}, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/phantom_forms/helper.rb', line 20 def normal_form_for(object, = {}, &block) [:validate] = true [:builder] = PhantomForms::FormBuilders::ValidateFormBuilder [:html] = {:class => 'normal-form form'} object_name = get_class(extract_object(object)) object_class = [:resource] || object_name label = [:label] || t("#{object_name.underscore}.singular") content_tag :div, class: "panel panel-primary" do concat(panel_title(label, (object_class))) unless label == 'nil' concat(content_tag(:div, class: "panel-body") { form_for(object, , &block) }) end end |
#normal_modal_form_for(object, options = {}, &block) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/phantom_forms/helper.rb', line 53 def normal_modal_form_for(object, = {}, &block) [:validate] = true [:builder] = PhantomForms::FormBuilders::ValidateFormBuilder [:html] = {:'data-type' => 'script', :class => 'normal-form'} object_name = get_class(extract_object(object)) object_class = [:resource] || object_name label = [:label] || t("#{object_name.underscore}.singular") content_tag :div, class: "panel panel-primary" do concat(panel_title(label, )) concat(content_tag(:div, class: "panel-body") { form_for(object, , &block) }) end end |
#remote_form_for(object, options = {}, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 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'} object_name = get_class(extract_object(object)) object_class = [:resource] || object_name label = [:label] || t("#{object_name.underscore}.singular") content_tag :div, class: "panel panel-primary" do concat(panel_title(label, (object_class))) concat(content_tag(:div, class: "panel-body") { form_for(object, , &block) }) end end |