Sha256: 28cd58289c95f148fdfc1f62c492beae68a8873651ecaf07ec4171dbbfda759b
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
class ShadcnFormBuilder < ActionView::Helpers::FormBuilder def label(method, options = {}) error_class = @object.errors[method].any? ? "error" : "" options[:class] = @template.tw("#{options[:class]} #{error_class}") @template.render_label(name: "#{object_name}[#{method}]", label: method.capitalize, **options) end def text_field(method, options = {}) options[:class] << " error" if @object.errors[method].any? @template.render_input( name: "#{object_name}[#{method}]", id: "#{object_name}_#{method}", value: @object.send(method), type: "text", **options ) end def password_field(method, options = {}) error_class = @object.errors[method].any? ? "error" : "" options[:class] = @template.tw("#{options[:class]} #{error_class}") @template.render_input( name: "#{object_name}[#{method}]", id: "#{object_name}_#{method}", value: @object.send(method), type: "password", **options ) end def email_field(method, options = {}) error_class = @object.errors[method].any? ? "error" : "" options[:class] = @template.tw("#{options[:class]} #{error_class}") @template.render_input( name: "#{object_name}[#{method}]", id: "#{object_name}_#{method}", value: @object.send(method), type: "email", **options ) end def submit(value = nil, options = {}) @template.render_button(value, **options) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shadcn-ui-0.0.10 | app/form_builders/shadcn_form_builder.rb |
shadcn-ui-0.0.8 | app/form_builders/shadcn_form_builder.rb |
shadcn-ui-0.0.5 | app/form_builders/shadcn_form_builder.rb |