aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/application_helper.rb
blob: b1c2b1eb021a84587d7832ac0ffaea26e5a70e41 (plain) (blame)
1
2
3
4
5
6
7
8
9
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