Class: Plutonium::UI::Form::Base::Builder
- Inherits:
-
Builder
- Object
- Builder
- Plutonium::UI::Form::Base::Builder
- Includes:
- Phlexi::Field::Common::Tokens, Options::InferredTypes
- Defined in:
- lib/plutonium/ui/form/base.rb
Instance Attribute Summary collapse
-
#as ⇒ Object
readonly
Returns the value of attribute as.
Instance Method Summary collapse
- #easymde_tag ⇒ Object (also: #markdown_tag)
- #flatpickr_tag ⇒ Object (also: #datetime_tag, #date_tag, #time_tag)
- #hidden? ⇒ Boolean
-
#initialize(*args, as: nil, **kwargs, &block) ⇒ Builder
constructor
Consume ‘:as` here so it doesn’t land in Phlexi’s ‘@options` — `:as` is a Plutonium-internal concept (it picks the tag method), not a Phlexi field option.
- #int_tel_input_tag ⇒ Object (also: #phone_tag)
- #key_value_store_tag ⇒ Object (also: #hstore_tag, #key_value_tag)
- #resource_select_tag(**attributes) ⇒ Object
- #secure_association_tag(**attributes) ⇒ Object (also: #belongs_to_tag, #has_many_tag, #has_one_tag, #association_tag)
- #secure_polymorphic_association_tag(**attributes) ⇒ Object (also: #polymorphic_belongs_to_tag)
- #slim_select_tag(**attributes) ⇒ Object
- #textarea_tag(**attributes) ⇒ Object (also: #text_tag, #json_tag, #jsonb_tag)
- #uppy_tag ⇒ Object (also: #file_tag, #attachment_tag)
-
#wrapped ⇒ Object
Hidden fields (‘form.field(name, as: :hidden)`) skip the label / hint / error chrome and render inside a `<div hidden>` so they’re also excluded from CSS Grid / Flex layout.
Constructor Details
#initialize(*args, as: nil, **kwargs, &block) ⇒ Builder
Consume ‘:as` here so it doesn’t land in Phlexi’s ‘@options` —`:as` is a Plutonium-internal concept (it picks the tag method), not a Phlexi field option.
16 17 18 19 |
# File 'lib/plutonium/ui/form/base.rb', line 16 def initialize(*args, as: nil, **kwargs, &block) @as = as super(*args, **kwargs, &block) end |
Instance Attribute Details
#as ⇒ Object (readonly)
Returns the value of attribute as.
21 22 23 |
# File 'lib/plutonium/ui/form/base.rb', line 21 def as @as end |
Instance Method Details
#easymde_tag ⇒ Object Also known as: markdown_tag
40 41 42 |
# File 'lib/plutonium/ui/form/base.rb', line 40 def easymde_tag(**, &) create_component(Plutonium::UI::Form::Components::Easymde, :easymde, **, &) end |
#flatpickr_tag ⇒ Object Also known as: datetime_tag, date_tag, time_tag
50 51 52 |
# File 'lib/plutonium/ui/form/base.rb', line 50 def flatpickr_tag(**, &) create_component(Components::Flatpickr, :flatpickr, **, &) end |
#hidden? ⇒ Boolean
23 24 25 |
# File 'lib/plutonium/ui/form/base.rb', line 23 def hidden? as.to_s == "hidden" end |
#int_tel_input_tag ⇒ Object Also known as: phone_tag
54 55 56 |
# File 'lib/plutonium/ui/form/base.rb', line 54 def int_tel_input_tag(**, &) create_component(Components::IntlTelInput, :int_tel_input, **, &) end |
#key_value_store_tag ⇒ Object Also known as: hstore_tag, key_value_tag
65 66 67 |
# File 'lib/plutonium/ui/form/base.rb', line 65 def key_value_store_tag(**, &) create_component(Components::KeyValueStore, :key_value_store, **, &) end |
#resource_select_tag(**attributes) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/plutonium/ui/form/base.rb', line 69 def resource_select_tag(**attributes, &) attributes[:data_controller] = tokens(attributes[:data_controller], "slim-select") # class!: "" clears the underlying <select>'s themed classes # (pu-input etc.) — the visible element is slim-select's # generated .ss-main, so leaving Tailwind input chrome on the # native select can leak into chip layout (e.g. forcing # flex-direction: column or w-full on multi-mode chips). create_component(Components::ResourceSelect, :select, class!: "", **attributes, &) end |
#secure_association_tag(**attributes) ⇒ Object Also known as: belongs_to_tag, has_many_tag, has_one_tag, association_tag
79 80 81 82 |
# File 'lib/plutonium/ui/form/base.rb', line 79 def secure_association_tag(**attributes, &) attributes[:data_controller] = tokens(attributes[:data_controller], "slim-select") # TODO: put this behind a config create_component(Components::SecureAssociation, :association, **attributes, &) end |
#secure_polymorphic_association_tag(**attributes) ⇒ Object Also known as: polymorphic_belongs_to_tag
92 93 94 95 |
# File 'lib/plutonium/ui/form/base.rb', line 92 def secure_polymorphic_association_tag(**attributes, &) attributes[:data_controller] = tokens(attributes[:data_controller], "slim-select") # TODO: put this behind a config create_component(Components::SecurePolymorphicAssociation, :polymorphic_association, **attributes, &) end |
#slim_select_tag(**attributes) ⇒ Object
45 46 47 48 |
# File 'lib/plutonium/ui/form/base.rb', line 45 def slim_select_tag(**attributes, &) attributes[:data_controller] = tokens(attributes[:data_controller], "slim-select") select_tag(**attributes, required: false, class!: "", &) end |
#textarea_tag(**attributes) ⇒ Object Also known as: text_tag, json_tag, jsonb_tag
35 36 37 38 |
# File 'lib/plutonium/ui/form/base.rb', line 35 def textarea_tag(**attributes, &) attributes[:data_controller] = tokens(attributes[:data_controller], "textarea-autogrow") super end |
#uppy_tag ⇒ Object Also known as: file_tag, attachment_tag
59 60 61 |
# File 'lib/plutonium/ui/form/base.rb', line 59 def uppy_tag(**, &) create_component(Components::Uppy, :uppy, **, &) end |
#wrapped ⇒ Object
Hidden fields (‘form.field(name, as: :hidden)`) skip the label / hint / error chrome and render inside a `<div hidden>` so they’re also excluded from CSS Grid / Flex layout.
30 31 32 33 |
# File 'lib/plutonium/ui/form/base.rb', line 30 def wrapped(**, &) return Plutonium::UI::Form::Components::HiddenWrapper.new(self, &) if hidden? super end |