iconfu iconfu iconfu is the world's largest collection of free, open-source icons and it comes with a handy image editor, so you can tweak icons to suit your needs exactly or even draw your own from scratch
invert blue resize move up verbose drawmode lighter previews remove swap animator library library draw shift up make a copy large editor explorer your icon contract agreement tag

17 July 2008

Using checkbox for a multiple-value parameter in Rails

This wasn't obvious. Thanks to satish on rails I learned this is the way to do it:

 <input type="checkbox" name="customer[preferences][]" value="yellow"/>
 <input type="checkbox" name="customer[preferences][]" value="blue"/>
 etc

The extra [] at the end of the parameter name makes all the difference. In your controller, you can now reference

  params[:customer][:preferences]

and get a list.

2 comments:

  1. Thank you very much, this really helped me. Nice trick!
    ReplyDelete
  2. This was very helpful. Thnx
    ReplyDelete