Sha256: f2e6088373f8394ead5a388f59b07998b7b475c6465f87d0065b1bcaeb041eba

Contents?: true

Size: 1.04 KB

Versions: 1016

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Playbook
  module Forms
    class Builder
      class FormFieldBuilder < Module
        def initialize(method_name, kit_name:)
          define_method method_name do |name, props: {}, **options, &block|
            props[:label] = @template.label(@object_name, name) if props[:label] == true
            options = Hash(options)

            options[:skip_default_ids] = false unless options.key?(:skip_default_ids)
            options[:required] = true if props[:required]
            options[:placeholder] = props[:placeholder] || ""

            if props.key?(:validation)
              validation = props[:validation]
              options[:pattern] = validation[:pattern] if validation[:pattern].present?
              options[:data] = { message: validation[:message] } if validation[:message].present?
            end

            input = super(name, **options, &block)

            @template.pb_rails(kit_name, props: props) do
              input
            end
          end
        end
      end
    end
  end
end

Version data entries

1,016 entries across 1,016 versions & 1 rubygems

Version Path
playbook_ui-14.8.0.pre.alpha.PLAY1649rolloutheightglobalprops4635 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.9.0.pre.rc.8 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.PLAY1598floatinguiupgrade4617 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.9.0.pre.rc.7 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.9.0.pre.rc.6 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.9.0.pre.rc.5 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.pbntr661createstickyleftprop4612 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.play1648heightglobalprops4606 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.9.0.pre.rc.4 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.9.0.pre.rc.3 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.9.0.pre.rc.2 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4567 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4565 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.PLAY1598floatinguiupgrade4563 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.play1648heightglobalprops4559 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.9.0.pre.rc.1 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.PLAY16254545 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.PLAY1615movenegativetoleftofcurrencysign4543 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.8.0.pre.alpha.PLAY1615movenegativetoleftofcurrencysign4539 lib/playbook/forms/builder/form_field_builder.rb
playbook_ui-14.9.0.pre.rc.0 lib/playbook/forms/builder/form_field_builder.rb