Skip to content

Instantly share code, notes, and snippets.

@adrianvalenz
Created October 23, 2022 10:21
Show Gist options
  • Save adrianvalenz/a76ab4104b41b189f5c72ae13835b2ad to your computer and use it in GitHub Desktop.
Save adrianvalenz/a76ab4104b41b189f5c72ae13835b2ad to your computer and use it in GitHub Desktop.
class SourdoughFormBuilder < ActionView::Helpers::FormBuilder
def check_box(attribute, options={})
super(attribute, options.reverse_merge(class: "check-box-styles"))
end
def date_field(attribute, options={})
super(attribute, options.reverse_merge(class: "date-field-styles"))
end
def datetime_field(attribute, options={})
super(attribute, options.reverse_merge(class: "datetime-field-styles"))
end
def email_field(attribute, options={})
super(attribute, options.reverse_merge(class: "email-field-styles"))
end
def file_field(attribute, options={})
super(attribute, options.reverse_merge(class: "file-field-styles"))
end
def label(attribute, options={})
super(attribute, options.reverse_merge(class: "label-field-styles"))
end
def number_field(attribute, options={})
super(attribute, options.reverse_merge(class: "number-field-styles"))
end
def password_field(attribute, options={})
super(attribute, options.reverse_merge(class: "password-field-styles"))
end
# def text_area(attribute, options={})
# super(attribute, options.reverse_merge(class: "text-area-styles"))
# end
def text_field(attribute, options={})
super(attribute, options.reverse_merge(class: "text-field-styles"))
end
# Methods that still need implementation
#
# clear_button(field_to_clear)
# collection_select(attribute, collection, value_method, text_method, options={}, html_options = {})
# radio_button(attribute, tag_value, options={})
# search_field(attribute, options={})
# select(attribute, choices=nil, options={}, html_options{}, &block)
#
end
@adrianvalenz
Copy link
Author

implement in form with builder: SourdoughFormBuilder and if using tailwind add the builders directory to the tw config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment