Value of union type attribute is not loaded on form
Closed this issue · 0 comments
nallwhy commented
Describe the bug
Value of union type attribute is not loaded on form
defmodule Post do
use Ash.Resource, data_layer: Ash.DataLayer.Ets, domain: Domain
attributes do
uuid_primary_key :id
attribute :title, :string, allow_nil?: false
attribute :content, Content, allow_nil?: false
end
actions do
defaults [create: [:title, :content], update: [:title, :content]]
end
end
# new post with content
post =
Post
|> Ash.Changeset.new()
|> Ash.Changeset.change_attributes(%{
title: "title",
content: %{"type" => "normal", "body" => "body"}
})
|> Ash.create!()
# create form for update
post
|> AshPhoenix.Form.for_update(:update, forms: [auto?: true])
|> to_form()
But value of input element of form[:content][:body] is empty.
To Reproduce
https://gist.github.com/nallwhy/bab128b393e4a1db5ae514ea06e57a31
initial value of content is %{body: "body"}
, but it's not loaded on form
Expected behavior
value is loaded on form
Runtime
- Elixir version: 1.16.1
- Erlang version: 26
- OS: mac
- Ash version: 3.0.0-rc.36
- any related extension versions
- Ash Phoenix version: 2.0.0-rc.8
Additional context
Add any other context about the problem here.