allanegidio

allanegidio

Phoenix doesn't show errors in all multi step form

Hello guys.

I’ve been having some trouble to understand this behaviour about liveview, live_flash and multi step forms.
It would be great if someone could be able to explain why this is not working.

I create a Multi step form on live view to test how it works and reach what I expected.

  • At first time, I want form be fullfilled without show any error.
  • Only show can’t be blank errors when I submit the form on step 3

https://github.com/allanegidio/multi_step_form

I followed the documentation and had success in my implementation but there’s one thing that I was not able to understand. I’m trying to not depends of class css “alert” in my live_flash so in this case I added this clause “if” in my live.html.heex
https://github.com/allanegidio/multi_step_form/blob/main/lib/multi_step_form_web/templates/layout/live.html.heex

Because of this “if” in live.html.heex my multi-step-form right now needs to be submitted two times to show erros in all steps. If a go to step 3 and submit at first time, errors only show on step 3 and if I go back to step 2 or 1 nothing will be showed.
If I remove this clause, everything works ok but I really would like to understand why.

To reproduce you can do:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server
  • Open localhost:4000/multi-step-form
  • Go to step 3 and submit only once the form and go back to step 2 or 1 to see that only step 3 show errors.
  • Refresh page and go to step 3 and submit form two times and go back to step 2 or 1 and see everything works normally.

Someone can understand why this is happening just because of this “if” clause on live.html.heex?

@update

I created another project using Phoenix 1.7 and I got the same error using everything default.
Maybe I made some mistake? I can’t understand why it’s only works normally if I do two submits.

to reproduce you can do the same above on version 1.6

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New

Other popular topics Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
New
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement