demarches-normaliennes/app/models/champs/checkbox_champ.rb
2024-08-22 09:26:48 +02:00

35 lines
708 B
Ruby

# frozen_string_literal: true
class Champs::CheckboxChamp < Champs::BooleanChamp
def mandatory_blank?
mandatory? && (blank? || !true?)
end
def legend_label?
false
end
def self.options
[[I18n.t('activerecord.attributes.type_de_champ.type_champs.checkbox_true'), true], [I18n.t('activerecord.attributes.type_de_champ.type_champs.checkbox_false'), false]]
end
# TODO remove when normalize_checkbox_values is over
def true?
value_with_legacy == TRUE_VALUE
end
def html_label?
false
end
def single_checkbox?
true
end
private
# TODO remove when normalize_checkbox_values is over
def value_with_legacy
value == 'on' ? TRUE_VALUE : value
end
end