Class: Headmin::Form::CheckboxView
Instance Method Summary
collapse
Methods inherited from ViewModel
#attributes, #initialize, #to_hash
Constructor Details
This class inherits a constructor from ViewModel
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class ViewModel
Instance Method Details
#checked_value ⇒ Object
9
10
11
|
# File 'app/models/headmin/form/checkbox_view.rb', line 9
def checked_value
@checked_value || "1"
end
|
17
18
19
20
21
|
# File 'app/models/headmin/form/checkbox_view.rb', line 17
def input_options
keys = attributes - %i[attribute form label validate wrapper checked_value unchecked_value]
options = to_h.slice(*keys)
default_input_options.deep_merge(options)
end
|
#label_options ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'app/models/headmin/form/checkbox_view.rb', line 23
def label_options
{
class: ["form-check-label"],
attribute: attribute,
form: form,
required: required,
text: label
}
end
|
#unchecked_value ⇒ Object
13
14
15
|
# File 'app/models/headmin/form/checkbox_view.rb', line 13
def unchecked_value
@unchecked_value || "0"
end
|
#wrapper_options ⇒ Object
33
34
35
36
37
38
39
|
# File 'app/models/headmin/form/checkbox_view.rb', line 33
def wrapper_options
default_wrapper_options.deep_merge(
{
class: %w[form-check mb-3]
}
).deep_merge(@wrapper || {})
end
|