Method: Voom::Presenters::DSL::Components::Lists::Line#checkbox

Defined in:
lib/voom/presenters/dsl/components/lists/line.rb

#checkbox(**attributes, &block) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/voom/presenters/dsl/components/lists/line.rb', line 69

def checkbox(**attributes, &block)
  return @checkbox if locked?

  # Append [] if the list is selectable and the checkbox's name
  # doesn't already include brackets:
  field_name = attributes.delete(:name).to_s
  field_name += '[]' if @selectable && !field_name.include?('[')

  @checkbox = Components::Checkbox.new(parent: self,
                                       name: field_name,
                                       **attributes,
                                       &block)
end