Module: Proscenium::UI::Form::FieldMethods
- Included in:
- Proscenium::UI::Form
- Defined in:
- lib/proscenium/ui/form/field_methods.rb
Instance Method Summary collapse
- #checkbox_field(*args, **attributes) ⇒ Object
- #combobox_field(*args, **attributes) ⇒ Object
- #datetime_local_field(*args, **attributes) ⇒ Object
-
#hidden_field(*args) ⇒ Object
Renders a hidden input field.
- #radio_field ⇒ Object
-
#radio_group(*args, **attributes) ⇒ Object
Renders a group of radio inputs for each option of the given ‘field`.
- #radio_input(*args) ⇒ Object
- #rich_textarea_field(*args, **attributes) ⇒ Object
- #select_country_field(*args, **attributes) ⇒ Object
- #select_field(*args, **attributes) ⇒ Object
- #tel_field(*args, **attributes) ⇒ Object
-
#textarea_field(*args, **attributes) ⇒ Object
Renders a <textarea> field for the given ‘attribute`.
Instance Method Details
#checkbox_field(*args, **attributes) ⇒ Object
29 30 31 32 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 29 def checkbox_field(*args, **attributes) merge_bang_attributes! args, attributes render Fields::Checkbox.new(args, @model, self, **attributes) end |
#combobox_field(*args, **attributes) ⇒ Object
90 91 92 93 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 90 def combobox_field(*args, **attributes) merge_bang_attributes! args, attributes render Fields::Combobox.new(args, @model, self, **attributes) end |
#datetime_local_field(*args, **attributes) ⇒ Object
22 23 24 25 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 22 def datetime_local_field(*args, **attributes) merge_bang_attributes! args, attributes render Fields::Datetime.new(args, @model, self, **attributes) end |
#hidden_field(*args) ⇒ Object
Renders a hidden input field.
9 10 11 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 9 def hidden_field(*args, **) render Fields::Hidden.new(args, @model, self, **) end |
#radio_field ⇒ Object
80 81 82 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 80 def radio_field(...) div { radio_input(...) } end |
#radio_group(*args, **attributes) ⇒ Object
Renders a group of radio inputs for each option of the given ‘field`.
74 75 76 77 78 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 74 def radio_group(*args, **attributes) attributes[:options] = args.pop if args.last.is_a?(Array) render Fields::RadioGroup.new(args, @model, self, **attributes) end |
#radio_input(*args) ⇒ Object
84 85 86 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 84 def radio_input(*args, **) render Fields::RadioInput.new(args, @model, self, **) end |
#rich_textarea_field(*args, **attributes) ⇒ Object
15 16 17 18 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 15 def rich_textarea_field(*args, **attributes) merge_bang_attributes! args, attributes render Fields::RichTextarea.new(args, @model, self, **attributes) end |
#select_country_field(*args, **attributes) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 49 def select_country_field(*args, **attributes) merge_bang_attributes! args, attributes attributes[:typeahead] = true attributes[:options] = '/countries' attributes[:component_props] = { items_on_search: true, input_props: { required: attributes.delete(:required) } } select_field(*args, **attributes) end |
#select_field(*args, **attributes) ⇒ Object
43 44 45 46 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 43 def select_field(*args, **attributes, &) merge_bang_attributes! args, attributes, additional_bang_attrs: [:typeahead] render Fields::Select.new(args, @model, self, **attributes, &) end |
#tel_field(*args, **attributes) ⇒ Object
36 37 38 39 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 36 def tel_field(*args, **attributes) merge_bang_attributes! args, attributes render Fields::Tel.new(args, @model, self, **attributes) end |
#textarea_field(*args, **attributes) ⇒ Object
Renders a <textarea> field for the given ‘attribute`.
65 66 67 68 |
# File 'lib/proscenium/ui/form/field_methods.rb', line 65 def textarea_field(*args, **attributes) merge_bang_attributes! args, attributes render Fields::Textarea.new(args, @model, self, **attributes) end |