diff options
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..b1c2b1e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,10 @@ module ApplicationHelper + def required_label_tag(form, field, text = nil) + label_content = text || field.to_s.titleize + required = form.object.class.validators_on(field).any? { |v| v.is_a?(ActiveRecord::Validations::PresenceValidator) } + + form.label field, class: "font-bold" do + required ? "#{label_content} <span class='text-red-500'>*</span>".html_safe : label_content + end + end end |