Class: Shadcn::FormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Shadcn::FormBuilder
- Defined in:
- app/components/shadcn/form_builder.rb
Instance Method Summary collapse
- #email_field(method, options = {}) ⇒ Object
- #label(method, options = {}) ⇒ Object
- #password_field(method, options = {}) ⇒ Object
- #submit(value = nil, options = {}) ⇒ Object
- #text_area(method, options = {}) ⇒ Object
- #text_field(method, options = {}) ⇒ Object
Instance Method Details
#email_field(method, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'app/components/shadcn/form_builder.rb', line 30 def email_field(method, = {}) error_class = @object.errors[method].any? ? "error" : "" [:class] = @template.tw("#{[:class]} #{error_class}") @template.render_input( name: "#{object_name}[#{method}]", id: "#{object_name}_#{method}", value: @object.send(method), type: "email", ** ) end |
#label(method, options = {}) ⇒ Object
2 3 4 5 6 |
# File 'app/components/shadcn/form_builder.rb', line 2 def label(method, = {}) error_class = @object.errors[method].any? ? "error" : "" [:class] = @template.tw("#{[:class]} #{error_class}") @template.render_label(name: "#{object_name}[#{method}]", label: label_for(@object, method), **) end |
#password_field(method, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/components/shadcn/form_builder.rb', line 19 def password_field(method, = {}) error_class = @object.errors[method].any? ? "error" : "" [:class] = @template.tw("#{[:class]} #{error_class}") @template.render_input( name: "#{object_name}[#{method}]", id: "#{object_name}_#{method}", value: @object.send(method), type: "password", ** ) end |
#submit(value = nil, options = {}) ⇒ Object
52 53 54 |
# File 'app/components/shadcn/form_builder.rb', line 52 def submit(value = nil, = {}) @template.(value, **) end |
#text_area(method, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/shadcn/form_builder.rb', line 41 def text_area(method, = {}) error_class = @object.errors[method].any? ? "error" : "" [:class] = @template.tw("#{[:class]} #{error_class}") @template.render_textarea( name: "#{object_name}[#{method}]", id: "#{object_name}_#{method}", value: @object.send(method), type: "text", ** ) end |
#text_field(method, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/components/shadcn/form_builder.rb', line 8 def text_field(method, = {}) error_class = @object.errors[method].any? ? "error" : "" [:class] = @template.tw("#{[:class]} #{error_class}") @template.render_input( name: "#{object_name}[#{method}]", id: "#{object_name}_#{method}", value: @object.send(method), type: "text", ** ) end |