Sha256: 667e45650b085637814c19b24c8f530414da49d993e6d00246a6e87895658d4e

Contents?: true

Size: 974 Bytes

Versions: 21

Compression:

Stored size: 974 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
        {
          url: "",
          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

21 entries across 21 versions & 1 rubygems

Version Path
playbook_ui-8.3.0.alpha.select.pre.margin app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.3.0 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.1.pre.alpha5 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.1.pre.alpha4 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.1.alpha.iconacc app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.1.pre.alpha3 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.1.pre.alpha2 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.3.0.deps2 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.3.0.pre.alpha1 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.1.pre.alpha1 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.1 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.0 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.1.2 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.1.0.pre.alpha1 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.0.3 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.0.pre.alpha2 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.1.1 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.0.2 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.2.0.pre.alpha1 app/pb_kits/playbook/pb_form/form_with.rb
playbook_ui-8.1.0 app/pb_kits/playbook/pb_form/form_with.rb