Module: Agilibox::FormHelper
Instance Method Summary collapse
- #checkboxes_dropdown(f, input, collection, label = t("actions.select")) ⇒ Object
- #form_buttons(opts = {}) ⇒ Object
-
#form_hidden_submit ⇒ Object
Hidden submit to be the default triggered on <enter> keypress on a form.
- #horizontal_form_for(obj, opts = {}, &block) ⇒ Object
- #search_form(action: request.fullpath) ⇒ Object
Methods included from I18nHelper
Instance Method Details
#checkboxes_dropdown(f, input, collection, label = t("actions.select")) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'app/helpers/agilibox/form_helper.rb', line 54 def checkboxes_dropdown(f, input, collection, label = t("actions.select")) render("agilibox/forms/checkboxes_dropdown", :f => f, :input => input, :collection => collection, :label => label, ) end |
#form_buttons(opts = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/agilibox/form_helper.rb', line 9 def (opts = {}) back_url = opts[:back_url] back_url = url_for(:back).html_safe if back_url.nil? back_url = URI(back_url).path if back_url.to_s.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 form-actions") do submit = content_tag(:button, type: :submit, class: "btn btn-sm btn-success form-submit") do content_tag(:span, class: "fa fa-save") {} + " " + ta(submit_action) end cancel = content_tag("a", href: back_url, class: "btn btn-primary btn-sm form-cancel") do content_tag(:span, class: "fa fa-times") {} + " " + ta(:cancel) end cancel = "" if back_url == false submit + cancel end end |
#form_hidden_submit ⇒ Object
Hidden submit to be the default triggered on <enter> keypress on a form
5 6 7 |
# File 'app/helpers/agilibox/form_helper.rb', line 5 def form_hidden_submit tag(:input, type: "submit", class: "hidden-submit") end |
#horizontal_form_for(obj, opts = {}, &block) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'app/helpers/agilibox/form_helper.rb', line 39 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(action: request.fullpath) ⇒ Object
50 51 52 |
# File 'app/helpers/agilibox/form_helper.rb', line 50 def search_form(action: request.fullpath) render "agilibox/search/form", action: action end |