Has_many not populated with existing values in edit
Created by: monkbroc
When opening the edit page for a resource with an has_many relation, none of the option tags generated for the select tag have the "selected" attribute set so existing values are lost on save.
You can reproduce this on the demo server:
- Go to an order page with items https://administrate-prototype.herokuapp.com/admin/orders/331/
- Click Edit
- See that the line items ids field is blank
- Click Save
- See that the line items are gone.
Here's my workaround in app/views/fields/has_many/_form.html.erb
<%= f.select(field.attribute_key, nil, {}, multiple: true) do %>
<%= options_for_select(field.associated_resource_options, field.data.map(&:id)) %>
<% end %>
I can make a PR to fix this properly if you want.
This issue is similar to #241 (closed)