Sha256: 99203230edbbfe3ee2af18acfea35efae4dc57bd009d1ea3f8e64d0a309253f4

Contents?: true

Size: 837 Bytes

Versions: 15

Compression:

Stored size: 837 Bytes

Contents

# frozen_string_literal: true
module UiComponents
  class ValidatedOpenStruct < OpenStruct
    def self.validators_on(*)
      []
    end
  end

  module FormHelper
    # TODO: Move to own component.
    def modelless_form(options, &block)
      model_params = options[:params] || params[options[:name]]
      struct = ValidatedOpenStruct.new(model_params)
      bootstrap_form_for(
        struct,
        as: options[:name],
        url: options[:url].to_s,
        method: options.fetch(:method, :post),
        &block
      )
    end

    # TODO: Move to DatagridFilterCell or own component.
    def datagrid_filters(form, filters, options = {})
      filter_markup = filters.map do |filter|
        ui_component(:datagrid_filter, options.merge(form: form, filter: filter))
      end

      safe_join filter_markup
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ad2games-ui_components-2.3.0 lib/ui_components/form_helper.rb
ad2games-ui_components-2.1.0 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.14 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.12 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.11 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.10 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.9 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.8 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.7 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.5 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.4 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.3 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.2 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.1 lib/ui_components/form_helper.rb
ad2games-ui_components-2.0.0 lib/ui_components/form_helper.rb