Skip to content

Commit

Permalink
Properly localise FormsHelper helpers
Browse files Browse the repository at this point in the history
These should use `full_messages` to get the field names from i18n,
rather than just humanizing the field name.
  • Loading branch information
csutter committed Jun 19, 2024
1 parent b747714 commit c0c4ccf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/helpers/forms_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ module FormsHelper
def error_items(record, field)
return unless record.errors[field].any?

record.errors[field].map do |error|
{ text: "#{field.to_s.humanize} #{error}" }
record.errors.full_messages_for(field).map do |error|
{ text: error }
end
end

def error_summary_items(record)
record.errors.map do |error|
{
text: "#{error.attribute.to_s.humanize} #{error.message}",
text: error.full_message,
href: "##{record.class.name.underscore}_#{error.attribute}",
}
end
Expand Down

0 comments on commit c0c4ccf

Please sign in to comment.