scribe/src/components/shared/field_errors.cr
Edward Loveall fcf3eb14d0
Initial app
2021-05-01 17:03:38 -04:00

16 lines
335 B
Crystal

class Shared::FieldErrors(T) < BaseComponent
needs attribute : Avram::PermittedAttribute(T)
def render
unless attribute.valid?
div class: "error" do
text "#{label_text} #{attribute.errors.first}"
end
end
end
def label_text : String
Wordsmith::Inflector.humanize(attribute.name.to_s)
end
end