Closed Manukam closed 1 year ago
Hi @Manukam I think this will not work in the current implementation, you need to pass only value from money struct. I will experiment how to implement it
Hi @Nitrino, thanks for the quick reply. I will provide more information. This is how I have defined the schema,
@type t() :: %__MODULE__{
name: String.t(),
cost: Money.Ecto.Amount.Type
}
embedded_schema do
field :name, :string
field :cost, Money.Ecto.Amount.Type
end
In the form, this is a add more use case. Using a button the user can add more of these to the form,
impl true
def handle_event("add_more", _params, socket) do
socket.assigns.something
|> Map.update!(:field, &(&1 ++ [%Struct{}]))
|> update_something(socket)
end
During this handle_event
this error pops up
** (Protocol.UndefinedError) protocol Phoenix.HTML.Safe not implemented for %{"amount" => 100000, "currency" => :EUR} of type Map.
I have defined
Money.Ecto.Amount.Type
in an embedded schema, and I am trying to render the amount as shown below,<%= text_input(fd, :cost, class: input_class) %>
This gives the above error
Money - 1.12