Hello,
I have two entities in a many-to-many relationship, Client
and Service
.
In the Client
schema I have the relationship defined as:
many_to_many :services, MyApp.Customers.Service, join_through: "client_service",
on_delete: :delete_all,
on_replace: :delete
And the form has the following line:
<%= multiple_select f, :services, Enum.map(@services, &({&1.name, &1.id})), class: "selectpicker" %>
When I submit the form for an insert, it works perfectly. However, when I try to open the edit page, I get the following error:
protocol Phoenix.HTML.Safe not implemented for #Ecto.Changeset<action: :replace, changes: %{}, errors: [], data: #MyApp.Customers.Service<>, valid?: true>
If I understood correctly, it is trying to use the changeset to fill the data in the muliple_select. I’m missing something?
I’m sure that that I preloaded all associations, but even reading the documentation I couldn’t figure it out