tmbb
Reordering nested form inputs with buttons (not drag and drop!)
There are some online examples on how to reorder nested form inputs built with <.inputs_for/> using the Sortable.js library and streams. It’s all based on the new :sort_param provided by ecto.
I have a form with nested inputs in which I’d prefer not to use streams because there are several levels of nesting and I didn’t want to have to traverse the changeset to convert everything into streams and I don’t want to use drag and drop because the items to be reordered are quite “tall” and fill up too much of the screen to be dragged around easily.
From a UI point of view, I’d like to add buttons to move an element up the list (thus swapping it with the element above) and to move an element down (thus swapping it with the element below).
I’m having a real hard time with this, though. My naive solutions of updating the values of the :sort_param fields and emitting a change event are not working like I wanted, and I wonder if anyone else has already implemented this in a way that works.
First Post!
codeanpeace
Could you share what you tried and describe what isn’t working? Are you successfully updating/persisting the :sort_param aka position field and just having trouble with that change event?
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








