Sha256: a494a277e481a50f79fd59bd01a588d6e3c76cb3f45439629725d75a31627679

Contents?: true

Size: 955 Bytes

Versions: 5

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

module Playbook
  module PbForm
    class FormWith < Playbook::KitBase
      class FormBuilder < ::ActionView::Helpers::FormBuilder
        include ::Playbook::PbForm::FormBuilder
      end

      prop :options, type: Playbook::Props::Hash, default: {}
      prop :validate, type: Playbook::Props::Boolean, default: false

      def data
        prop(:data).merge("pb-form-validation" => validate)
      end

      def form_options
        {
          id: id,
          aria: aria,
          class: classname,
          data: data,
          builder: ::Playbook::PbForm::FormWith::FormBuilder,
        }.merge(options)
      end

      def render_form(builder)
        view_context.capture(builder, &children)
      end

      def classname
        [generate_classname("pb-form"), options[:class]].join(" ")
      end

      def render_in(view_context, &_block)
        super(view_context, &nil)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
playbook_ui-8.1.3 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.4.0.alpha.dependencies.2 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.4.0.alpha.dependencies.1 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.0.pre.alpha4 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.0.pre.alpha3 app/pb_kits/playbook/pb_form/form_with.rb