Sha256: 9096191a10b4c21774fa1c1c60d386cd710eded821fd2e6535b62c14af733ace

Contents?: true

Size: 1.01 KB

Versions: 26

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbForm
    class Form < ::Playbook::KitBase
      prop :form_system, type: Playbook::Props::Enum,
                         values: %w[form_with simple_form],
                         default: "form_with"
      prop :form_system_options, type: Playbook::Props::Base
      prop :validate, type: Playbook::Props::Boolean, default: false

      def form_system_options
        form_options = prop(:form_system_options)
        if form_options.is_a?(::Array)
          model, options = *form_options
          (options || {}).merge(model: model)
        else
          form_options
        end
      end

      def render_in(view_context, &block)
        form_kit.render_in(view_context, &block)
      end

    private

      def form_kit
        @form_system ||= begin
          ::Playbook::KitResolver.resolve("form/#{form_system}")
                                 .new(options: form_system_options, validate: validate, children: children)
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
playbook_ui-8.3.0.alpha.select.pre.margin app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.3.0 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.1.pre.alpha5 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.1.pre.alpha4 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.1.alpha.iconacc app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.1.pre.alpha3 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.1.pre.alpha2 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.3.0.deps2 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.3.0.pre.alpha1 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.1.pre.alpha1 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.1 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.1.3 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.4.0.alpha.dependencies.2 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.4.0.alpha.dependencies.1 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.0.pre.alpha4 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.0.pre.alpha3 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.2.0 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.1.2 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.1.0.pre.alpha1 app/pb_kits/playbook/pb_form/form.rb
playbook_ui-8.0.3 app/pb_kits/playbook/pb_form/form.rb