josefrichter
LiveView: submit form and update URL
Hi, what is the correct way to update URL params upon submitting a form, please?
I have a search input field with standard submit button, that has phx-submit binding. But I want pagination on the search results, too.
Generally one would probably go to /users/search-results and then have prev/next live_patch links there.
But what if I wanted to stay on the same page, and just update params like /users?search=john&page=1&per_page=10? Therefore the whole thing working more like a text filter?
Basically, how do I get the value from form textfield into URL, please?
Thank you
Marked As Solved
cmo
In handle_event call push_patch(socket, to: Routes.live_path(socket, Something, %{search: "John", page: 1, per_page: 10}). Then you do the validation and assigning of params in handle_params.
Also Liked
cmo
Another post on this topic: LiveView push_patch append to params - #8 by josevalim
And yes to the above question.
Last Post!
josefrichter
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









