luckybooru/src/components/shared/field_errors.cr

14 lines
368 B
Crystal

class Shared::FieldErrors(T) < BaseComponent
needs field : Avram::PermittedAttribute(T)
# Customize the markup and styles to match your application
def render
unless @field.valid?
div class: "error" do
label_text = Wordsmith::Inflector.humanize(@field.name.to_s)
text "#{label_text} #{@field.errors.first}"
end
end
end
end