Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm trying to implement ordering a has_many association following the documentation (https://hexdocs.pm/ecto/3.10.1/Ecto.Changeset.html#cast_assoc/3-sorting-and-deleting-from-many-collections). As this lead to some problems that were fixed by elixir-ecto/ecto#4178 (not released yet), I switched to using the current ecto main branch and modified my code according to the new documentation, adding a cast function with arity three, that receives the index as third parameter. This works fine, but not when used in a phoenix form.
When using it together with Phoenix.Component's
inputs_for/1
, it fails with an error like this:So here's a PR that tries to add support for arity three cast functions. I'm not completely sure if I implemented this right, but it seems to work with the added test and also in my Phoenix app.
If I'm not on the right track here, see this as a bug report instead :)