Module: BMC::FormHelper
Instance Method Summary collapse
-
#form_hidden_submit ⇒ Object
Hidden submit to be the default triggered on <enter> keypress on a form Does not work if display:none.
- #hidden_inputs_for_get_form(url, except: nil, only: nil) ⇒ Object
- #search_form(action: request.fullpath, placeholder: ta(:search)) ⇒ Object
Methods included from I18nHelper
Instance Method Details
#form_hidden_submit ⇒ Object
Hidden submit to be the default triggered on <enter> keypress on a form Does not work if display:none
6 7 8 9 |
# File 'app/helpers/bmc/form_helper.rb', line 6 def form_hidden_submit css = "position:absolute;top:-9999px;left:-9999px;opacity:0;height:0;width:0;visibility: hidden" tag.input(type: "submit", class: "hidden-submit", style: css) end |
#hidden_inputs_for_get_form(url, except: nil, only: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/bmc/form_helper.rb', line 15 def hidden_inputs_for_get_form(url, except: nil, only: nil) query_values = Addressable::URI.parse(url).query_values.to_h.with_indifferent_access query_values.except!(*except) if except query_values.select! { only.map(&:to_sym).include?(_1.to_sym) } if only return if query_values.empty? query_values.sum("".html_safe) { |k, v| tag.input(type: "hidden", name: k, value: v) } end |
#search_form(action: request.fullpath, placeholder: ta(:search)) ⇒ Object
11 12 13 |
# File 'app/helpers/bmc/form_helper.rb', line 11 def search_form(action: request.fullpath, placeholder: ta(:search)) render "bmc/search/form", action:, placeholder: end |