# Using label helper with HABTM checkboxes

**URL:** <https://www.ruby-forum.com/t/using-label-helper-with-habtm-checkboxes/141376>\
**Category:** Rails\
**Created:** [June 25, 2008, 6:53am UTC](https://www.ruby-forum.com/t/using-label-helper-with-habtm-checkboxes/141376 "2008-06-25T06:53:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shenry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@shenry](https://www.ruby-forum.com/u/shenry)\
**Post date:** [June 25, 2008, 6:53am UTC](https://www.ruby-forum.com/t/using-label-helper-with-habtm-checkboxes/141376/1 "2008-06-25T06:53:02Z")

</div>

I have a list of category checkboxes whose HTML looks like this:

…from…  
check\_box\_tag(“categories[]”, cat[0], @post.categories.map {|c|  
c.id}.include?(cat[0]))

I’d like the label to select the checkbox it’s associated with… but  
all of the category names are “category[]”, so when I click any of the  
labels they all toggle the first checkbox.

How can I code the label tag to associate the label with the checkbox?

Thanks,

SH

PS: Ideally I’d like my params[:categories] to look like [1, 3, 5, 8]
