aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-11-14 11:12:36 +0000
committerMatthew Lemon <y@yulqen.org>2024-11-14 11:12:36 +0000
commit1062c6328f60bf9cacba20c07f5cd33e55c153ee (patch)
treeb780312b4fd1427707cbaecdc45711ea827b9fb8 /app/helpers
parente636e93c866b000ae4674605ea0543930c7e2e99 (diff)
Adds credits to resource and required asterisks on form
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb8
-rw-r--r--app/helpers/pdfresources_helper.rb2
2 files changed, 8 insertions, 2 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
diff --git a/app/helpers/pdfresources_helper.rb b/app/helpers/pdfresources_helper.rb
deleted file mode 100644
index 1f400cc..0000000
--- a/app/helpers/pdfresources_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module PdfresourcesHelper
-end