Sha256: 341ca017d8311fc89304670c41ce95ef1ea1c279524e88fc4de0c38c564b6c4a

Contents?: true

Size: 763 Bytes

Versions: 4

Compression:

Stored size: 763 Bytes

Contents

module BMC::FormHelper
  include BMC::I18nHelper

  # Hidden submit to be the default triggered on <enter> keypress on a form
  # Does not work if display:none
  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

  def search_form(action: request.fullpath)
    render "bmc/search/form", action: action
  end

  def hidden_inputs_for_get_form(url, except: [])
    query_values = Addressable::URI.parse(url).query_values.to_h
      .with_indifferent_access
      .except(*except)

    return if query_values.empty?

    query_values.sum("".html_safe) { |k, v| tag.input(type: "hidden", name: k, value: v) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bmc-1.3.2 app/helpers/bmc/form_helper.rb
bmc-1.3.1 app/helpers/bmc/form_helper.rb
bmc-1.3.0 app/helpers/bmc/form_helper.rb
bmc-1.2.1 app/helpers/bmc/form_helper.rb