AE
Ash Elixir•2y ago
Jason

submit_errors: [id: {"has already been taken", []}],

When a for_create form is submitted, I get this error. Assuming the id it's referring to is "form", I'm not sure why it thinks it has been taken.
api: MyApp.Tweets,
method: "post",
submit_errors: [id: {"has already been taken", []}],
id: "form",
transform_errors: nil,
...
api: MyApp.Tweets,
method: "post",
submit_errors: [id: {"has already been taken", []}],
id: "form",
transform_errors: nil,
...
The form is created using apply_action called from the mount action (similar to the Ash twitter clone example).
defp apply_action(socket, :new, _params) do
current_user = socket.assigns.current_user

form =
AshPhoenix.Form.for_create(MyApp.Tweets.Tweet, :create,
api: MyApp.Tweets,
forms: [
items: [
defp apply_action(socket, :new, _params) do
current_user = socket.assigns.current_user

form =
AshPhoenix.Form.for_create(MyApp.Tweets.Tweet, :create,
api: MyApp.Tweets,
forms: [
items: [
3 Replies
ZachDaniel
ZachDaniel•2y ago
it is not referring to the id "form" from the form, but the id being used to create the record I assume id is the primary key, but it looks like you're trying to use a primary key that has already been used.
Jason
JasonOP•2y ago
Ahh.. I see. Thank you. I have this to generate id in :create, and it seems to give me the same ID every time (even after the app is restarted). Does that sound likely?
change set_attribute(:id, Ash.UUID.generate())
change set_attribute(:id, Ash.UUID.generate())
ZachDaniel
ZachDaniel•2y ago
yep 🙂 &Ash.UUID.generate/0

Did you find this page helpful?