Module: Dorsale::FormHelper
- Included in:
- AllHelpers
- Defined in:
- app/helpers/dorsale/form_helper.rb
Instance Method Summary collapse
- #form_buttons(opts = {}) ⇒ Object
- #horizontal_form_for(obj, opts = {}, &block) ⇒ Object
- #search_form(opts = {}) ⇒ Object
Instance Method Details
#form_buttons(opts = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/dorsale/form_helper.rb', line 2 def (opts = {}) back_url = opts[:back_url] back_url = url_for(:back).html_safe if back_url.blank? back_url = URI(back_url).path if back_url.include?("://") if opts[:obj].present? if opts[:obj].new_record? submit_action = :create else submit_action = :update end else submit_action = :save end content_tag("div", class: "actions") do submit = content_tag(:button, type: :submit, class: "btn btn-sm btn-success") do content_tag(:span, class: "fa fa-save") {} + " " + t("actions.#{submit_action}") end cancel = content_tag("a", href: back_url, class: "btn btn-primary btn-sm") do content_tag(:span, class: "fa fa-times"){} + " " + t("actions.cancel") end cancel = "" if back_url == false submit + cancel end end |
#horizontal_form_for(obj, opts = {}, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/dorsale/form_helper.rb', line 32 def horizontal_form_for(obj, opts={}, &block) opts = { :wrapper => "horizontal_form", :html => { :class => "form-horizontal" } }.deep_merge(opts) simple_form_for(obj, opts, &block) end |
#search_form(opts = {}) ⇒ Object
43 44 45 46 47 |
# File 'app/helpers/dorsale/form_helper.rb', line 43 def search_form(opts = {}) action = opts.delete(:action) || request.fullpath render "dorsale/search/form", action: action end |