In order to actually render this, I've implemented the Phoenix.HTML.Safe protocol for Map (and all the other embedded schema types)
defimpl Phoenix.HTML.Safe, for: My.Embedded.Schema do
def to_iodata(data), do: Jason.encode!(data, escape: :html_safe, pretty: true)
end
defimpl Phoenix.HTML.Safe, for: Map do
def to_iodata(data), do: Jason.encode!(data, escape: :html_safe, pretty: true)
end
I also edited the update action within the generated controller to decode
case Admin.update_user_identity(
my_schema,
my_schema
|> Map.get_and_update("my_map_field", fn cv -> {cv, Jason.decode!(cv)} end)
|> elem(1)
) do
...
While I can continue to do this to get these fields working, I'm wondering if handling of these types can be automatically supported by Mandarin by default?
Willing to help out if needed on this one. Loving Mandarin so far.
Sorry for only answering now! I'll think about it. I have made some pretty important changes in Mandarin in the meantime, though. When I publish my changes I'll look into this issue.
:map
types and:embedded_schema
types lead to a brokeninput
right now.I've fixed it locally by editing the field in
edit.html.eex
to render a text area insteadIn order to actually render this, I've implemented the
Phoenix.HTML.Safe
protocol for Map (and all the other embedded schema types)I also edited the
update
action within the generated controller to decodeWhile I can continue to do this to get these fields working, I'm wondering if handling of these types can be automatically supported by Mandarin by default?
Willing to help out if needed on this one. Loving Mandarin so far.