Sha256: d62a9cb5c656f86ad7ee36c67b10268a19b0bff5452ca64c8cd2489fa6af436a

Contents?: true

Size: 629 Bytes

Versions: 10

Compression:

Stored size: 629 Bytes

Contents

module RailsStuff
  module Helpers
    module Forms
      # Returns hidden field tags for requested fields when they are present in params.
      # Usually used to bypass params in GET-forms.
      def hidden_params_fields(*fields)
        inputs = fields.flat_map do |field|
          next unless params.key?(field)
          val = params[field]
          if val.is_a?(Array)
            name = "#{field}[]"
            val.map { |str| [name, str] }
          else
            [[field, val]]
          end
        end
        safe_join inputs.map { |(name, val)| hidden_field_tag name, val if name }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rails_stuff-0.6.0 lib/rails_stuff/helpers/forms.rb
rails_stuff-0.6.0.rc3 lib/rails_stuff/helpers/forms.rb
rails_stuff-0.6.0.rc2 lib/rails_stuff/helpers/forms.rb
rails_stuff-0.6.0.rc1 lib/rails_stuff/helpers/forms.rb
rails_stuff-0.5.1 lib/rails_stuff/helpers/forms.rb
rails_stuff-0.5.0 lib/rails_stuff/helpers/forms.rb
rails_stuff-0.4.0 lib/rails_stuff/helpers/forms.rb
rails_stuff-0.3.0 lib/rails_stuff/helpers/forms.rb
rails_stuff-0.2.0 lib/rails_stuff/helpers/forms.rb
rails_stuff-0.1.0 lib/rails_stuff/helpers/forms.rb