Great! this mostly works.
I am getting some peculiar output though.
Here is a simplified version of my form:
= simple_form_for @inventory_order, :html => {:class => 'form-
horizontal'} do |f|
= f.error_notification
.form-inputs
= f.collection_check_boxes :part_order_ids,
@part_orders, :id, :name do |b|
= b.label
.form-actions
%a#add_inventory_item.btn{:href => '#'} Add Inventory Item
= f.button :submit
And the output:
<form accept-charset="UTF-8" action="/inventory/orders"
class="simple_form form-horizontal" id="new_inventory_order"
method="post" novalidate="novalidate">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓" />
<input name="authenticity_token" type="hidden"
value="iGSIkTLLa73qGHCYZ+cyV9UVt09ir+n3O9NkK9dzHRs=" />
</div>
<div class='form-inputs'>
<label for="inventory_order_part_order_ids_645">M-6799 -
MONKEY1</label>
<label for="inventory_order_part_order_ids_646">M-6799 - MEEP</
label>
<span>2</span>
<span>2</span>
<input name="inventory_order[part_order_ids][]" type="hidden"
value="" />
</div>
<div class='form-actions'>
<a class='btn' href='#' id='add_inventory_item'>Add Inventory
Item</a>
<input class="btn" name="commit" type="submit" value="Create
Order" />
</div>
</form>
Notice the 2 rogue <span>2</span>'s ? The number of times the span
occurs seems to have to do with how many items there are in the
collection. and the number (2) seems to reflect how deeply nested the
f.collection_check_boxes is?!
I can't seem to figure out where the spans are coming from. Any idea?
On May 22, 10:28 pm, Carlos Antonio da Silva
<
carlosantoniodasi...@gmail.com> wrote:
> You have to use f.collection_check_boxes manually, instead of f.association, and give the collection and label/value attributes as arguments, same as collection select. Using this, you'll be able to give a block to colleciton_check_boxes, that gets passed a simple builder that can help you generating everything you need.
>
> There's an example here:
https://github.com/plataformatec/simple_form/blob/master/lib/simple_f...