Sha256: 1094b87e2f869bdb9f557ad0b1d59c187bac6dad6a400e0689b95960794e8ce0

Contents?: true

Size: 878 Bytes

Versions: 4

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

module Phlexi
  module Form
    module Structure
      class Namespace < Phlexi::Field::Structure::Namespace
        class NamespaceCollection < Phlexi::Form::Structure::NamespaceCollection; end

        def submit_button(key = :submit_button, **, &)
          field(key).submit_button_tag(**, &)
        end

        def extract_input(params)
          if params.is_a?(Array)
            each_with_object({}) do |child, hash|
              hash.merge! child.extract_input(params[0])
            end
          elsif params.is_a?(Hash)
            input = each_with_object({}) do |child, hash|
              input = params[key].is_a?(Hash) ? params[key] : {}
              hash.merge! child.extract_input(input)
            end
            {key => input}
          else
            {key => {}}
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
phlexi-form-0.5.1 lib/phlexi/form/structure/namespace.rb
phlexi-form-0.5.0 lib/phlexi/form/structure/namespace.rb
phlexi-form-0.4.8 lib/phlexi/form/structure/namespace.rb
phlexi-form-0.4.7 lib/phlexi/form/structure/namespace.rb