Skip to content

Conversation

@nduitz
Copy link

@nduitz nduitz commented Aug 16, 2025

This fixes two things:

a) It picks up the correct action (not from the changeset but from the parent form)
b) It fixes handling parameters for cardinality :many

If you remove the first commit you will see the test is failing and it will produce the incorrect form.
Instead of generating two forms per polymorphic type it will generate only one form for the device type

@nduitz nduitz force-pushed the fix-param-handling branch from 16d7b24 to ed3e4fa Compare August 21, 2025 09:33
@rmoorman
Copy link

This PR seems to fix some of the immediate form validation problems I was having (even though the issue you were mentioning this PR in (#113) is about polymorphic_embeds_many, and I was having trouble with polymorphic_embeds_one).

There seems to be one failing test though

  1) test form with improved param handling for different param types (PolymorphicEmbedTest)
     test/polymorphic_embed_test.exs:3234
     Assertion with == failed
     code:  assert f.params == %{"ref" => "789"}
     left:  %{"0" => %{"ref" => "789"}, "1" => %{"address" => "012 Oak Ave"}}
     right: %{"ref" => "789"}

I am not sure why this is happening though, as right now I didn't dive deep enough into phoenix form handling yet. Maybe it is happening because recent changes in phoenix html/form handling?

Furthermore, you mentioned in #113 that there were issues with the sort params as well, specifically with the approach taken in this PR.

Did you find some time to have another look at this yet @nduitz ?

@nduitz
Copy link
Author

nduitz commented Oct 23, 2025

Hey there,
we are currently running this branch in our project which works well so far: https://github.com/nduitz/polymorphic_embed/commits/patch-2

One thing I noticed yesterday which caused me a lot of headaches was that polymorphic_embed_inputs_for does not render hidden id inputs even though we do not specify skip_hidden: true.
Will look into that once we finished implementing all forms and continue to refine them.

@nduitz
Copy link
Author

nduitz commented Oct 23, 2025

Hey there, we are currently running this branch in our project which works well so far: https://github.com/nduitz/polymorphic_embed/commits/patch-2

One thing I noticed yesterday which caused me a lot of headaches was that polymorphic_embed_inputs_for does not render hidden id inputs even though we do not specify skip_hidden: true. Will look into that once we finished implementing all forms and continue to refine them.

Never mind my comment about polymorphic_embed_inputs_for not rendering a hidden id field. That is the same for the inputs_for implementation of phoenix_live_view. Somehow I assumed inputs_for does this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants