mercredi 4 novembre 2015

having trouble understanding :multiple => true in a checkbox

I am very new to Ruby on Rails, I have inherited control of a Ruby/Rails web based database(created by another) for generating and tracking engineering functions. I use Aptana IDE.

My issue is that I am trying to use a form helper to select multiple values for our "product lines". I use 10 check boxes, and I get the correct output of one value if I don't use ":multiple => true".

See output image:

no multiple select

works as intended

    <%= f.check_box :product_line, {:class => "field"}, "A9", false %> A9

(10 times with different values where "A9" is, so there are ten checkbox's total, image shows "A7" check box returned)

By simply adding the :multiple => true, the output changes as seen in the image below:

see output image:

multiple select

returns too much

    <%= f.check_box :product_line, {:class => "field", :multiple => true}, "A9", false %> A9

Why are all of those "-" added before the output only if the multiple selection is made? I want it to return only comma separated values of the checkbox, i.e. " A9, A7"

      PRODUCT_LINES = [ "A9", "A7", "AG", "AF", "S3", "Legacy", "K/Kpro", "EMW", "HD", "Non-Metallic" ]

other ideas: Can I loop through an array of :product_line to get what im looking for instead? I was also playing with the multiple selection in a drop down menu but could never select a second option before the drop down returned and only selected my first selection.




Aucun commentaire:

Enregistrer un commentaire