ayrdim
Hey gang, I’ve got a simple form that I’m using to get some data from a textarea in liveview.
I don’t have a validate form handler so the form data on the server always has the textarea data as an empty string (it was set there in the mount function using to_form).
When I save the form I get the textarea data from the params passed into the handle_event function, then I return {:noreply, socket}.
After the save the textarea on the client keeps its state (i.e. the text I entered doesnt disappear) despite the servers textarea form data being that same empty string set in mount. This checks out as nothing has changed on the server to justify a re-render for the client for that textarea.
The weird part comes when I throw a put_flash into the mix.
If the save handler returns {:noreply, put_flash(socket, :info, “Great success”)} the flash causes the simple forms textarea to also be re-rendered on the client, which sets it to the empty string on the server.
This all boils down to the question “Why does the flash cause the simple forms textarea to be re-rendered given that the server shouldnt see a reason to re-render that component?” I was expecting the flash to be rendered and nothing else to change.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sodapopcan
This is expected behaviour. You need to track your form’s state if you want to keep it around. This would happen on any change to
assigns, not just flash.See this thread for discussion about it.
ayrdim
Yep, that thread pretty much answers all of my questions on the form re-rendering! Thank you!