diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index a49dbc9..bfc88d9 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -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 { diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d91d051..c8da15d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index 62ae990..cc40e65 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,8 +2,8 @@ en: activerecord: attributes: user: - email: E-mail - password: Password + email: e-mail + password: password users: registrations: new: