diff options
author | Matthew Lemon <y@yulqen.org> | 2024-11-14 11:12:36 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-11-14 11:12:36 +0000 |
commit | 1062c6328f60bf9cacba20c07f5cd33e55c153ee (patch) | |
tree | b780312b4fd1427707cbaecdc45711ea827b9fb8 /app/helpers/application_helper.rb | |
parent | e636e93c866b000ae4674605ea0543930c7e2e99 (diff) |
Adds credits to resource and required asterisks on form
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 |