extract rendering condition
This commit is contained in:
parent
465449e684
commit
6b3631dbfe
4 changed files with 25 additions and 18 deletions
|
@ -1,3 +1,7 @@
|
|||
class Champs::DropDownListChamp < Champ
|
||||
THRESHOLD_NB_OPTIONS_AS_RADIO = 5
|
||||
|
||||
def render_as_radios?
|
||||
drop_down_list.enabled_non_empty_options.size <= THRESHOLD_NB_OPTIONS_AS_RADIO
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,6 +23,10 @@ class Champs::MultipleDropDownListChamp < Champ
|
|||
value.present? ? selected_options.join(', ') : nil
|
||||
end
|
||||
|
||||
def render_as_checkboxes?
|
||||
drop_down_list.enabled_non_empty_options.size <= THRESHOLD_NB_OPTIONS_AS_CHECKBOX
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def format_before_save
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue