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.0.1 app/pb_kits/playbook/pb_form/form_with.rb