Class: Headmin::Form::CheckboxView

Inherits:
ViewModel
  • Object
show all
Includes:
Hintable, Labelable, Validatable, Wrappable
Defined in:
app/models/headmin/form/checkbox_view.rb

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_valueObject



9
10
11
# File 'app/models/headmin/form/checkbox_view.rb', line 9

def checked_value
  @checked_value || "1"
end

#input_optionsObject



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_optionsObject



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_valueObject



13
14
15
# File 'app/models/headmin/form/checkbox_view.rb', line 13

def unchecked_value
  @unchecked_value || "0"
end

#wrapper_optionsObject



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