Sha256: ed1f63ba7e1122edc3539aba6047889650a8171436f3af13a928d1c7d2f269a0

Contents?: true

Size: 749 Bytes

Versions: 4

Compression:

Stored size: 749 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 { |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.2.0 app/helpers/bmc/form_helper.rb
bmc-1.1.0 app/helpers/bmc/form_helper.rb
bmc-1.0.1 app/helpers/bmc/form_helper.rb
bmc-1.0.0 app/helpers/bmc/form_helper.rb