Method: Satis::Switch::Component#initialize
- Defined in:
- app/components/satis/switch/component.rb
#initialize(form:, attribute:, **options, &block) ⇒ Component
Returns a new instance of Component.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/components/satis/switch/component.rb', line 8 def initialize(form:, attribute:, **, &block) super @form = form @attribute = attribute @options = @block = block @icon = true @icon = [:icon] if .key?(:icon) @value = .key?(:value) ? [:value] : @form.object.send(attribute) @value = @value == '0' || !@value ? false : true [:input_html] ||= {} [:input_html] = { data: { 'satis-switch-target' => 'hiddenInput' } }.deep_merge([:input_html]) end |