Class: Formstrap::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
8
9
10
|
# File 'app/models/formstrap/checkbox_view.rb', line 8
def checked_value
@checked_value || "1"
end
|
16
17
18
19
20
|
# File 'app/models/formstrap/checkbox_view.rb', line 16
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
22
23
24
25
26
27
28
29
30
|
# File 'app/models/formstrap/checkbox_view.rb', line 22
def label_options
{
class: ["form-check-label"],
attribute: attribute,
form: form,
required: required,
text: label
}
end
|
#unchecked_value ⇒ Object
12
13
14
|
# File 'app/models/formstrap/checkbox_view.rb', line 12
def unchecked_value
@unchecked_value || "0"
end
|
#wrapper_options ⇒ Object
32
33
34
35
36
37
38
|
# File 'app/models/formstrap/checkbox_view.rb', line 32
def wrapper_options
default_wrapper_options.deep_merge(
{
class: %w[form-check mb-3]
}
).deep_merge(@wrapper || {})
end
|