Module: ThroughCheckboxes::CheckboxesforHelpers::FormBuilderExtension

Defined in:
lib/throughcheckboxes/checkboxes_for_helpers.rb

Instance Method Summary collapse

Instance Method Details

#checkboxes_for(relation) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/throughcheckboxes/checkboxes_for_helpers.rb', line 7

def checkboxes_for(relation)
    output = ""
    output << "#{self.label(relation)}<br />"
    for record in ThroughCheckboxes::Core.relation_klass(self.object.class, relation).all
        output << @template.check_box_tag("#{@object_name}[#{relation}_ids][]",record.id,self.object.send(relation).include?(record))
        output << "#{record}<br />"
    end
    output << @template.hidden_field_tag("#{@object_name}[#{relation}_ids][]")
    output.html_safe
end