Lowercase attribute names

This commit is contained in:
cryptogopher 2023-04-13 21:09:58 +02:00
parent bd2557d261
commit a13c0ee5fe
3 changed files with 16 additions and 12 deletions

View File

@ -158,10 +158,10 @@ form tr td:first-child {
padding-right: 0.25rem;
text-align: right;
}
form td.required {
form label.required {
font-weight: bold;
}
form td.error {
form label.error {
color: #ff1f5b;
}
form em {

View File

@ -4,20 +4,24 @@ module ApplicationHelper
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{selector}(method, options = {})
@template.content_tag :tr do
label_text = label(method, options.delete(:label))
if options[:hint]
label_text += @template.tag(:br) + @template.content_tag(:em, options.delete(:hint))
end
label_class = @template.class_names(required: options[:required],
error: @object&.errors[method].present?)
@template.content_tag(:td, label_text, class: label_class) +
@template.content_tag(:td, label_for(method, options)) +
@template.content_tag(:td, super)
end
end
RUBY_EVAL
end
def label_for(method, options = {})
text = options.delete(:label)
text ||= @object.class.human_attribute_name(method).capitalize
classes = @template.class_names(required: options[:required],
error: @object&.errors[method].present?)
label(method, text, class: classes) +
(@template.tag(:br) + @template.content_tag(:em, options.delete(:hint)) if options[:hint])
end
def submit(value, options = {})
@template.content_tag :tr do
@template.content_tag :td, super, colspan: 2

View File

@ -2,8 +2,8 @@ en:
activerecord:
attributes:
user:
email: E-mail
password: Password
email: e-mail
password: password
users:
registrations:
new: