No route found for POST, form event phx1.6

Using phx 1.6, in .heex:

                <.form let={f} for={@changeset}, phx-change="validate", phx-submit: "add_match_result">

                  <%= inputs_for f, :embed, fn ff -> %>
                    <div class="mb-4">
                      <%= label ff, :name1 %>
                      <%= text_input ff, :name1, class: "form-control" %>
                      <%= error_tag ff, :name1 %>
                    <div class="mb-4">
                      <%= label ff, :name2 %>
                      <%= text_input ff, :name2, class: "form-control" %>
                      <%= error_tag ff, :name2 %>
                  <% end %>
                  <%= submit "Check it" %>

I get the error no route found for POST which for me means that the form make a post request, and not through the web socket. However, the layout is using the liveview render.
I also tried to "#" and phx_target: @myself but nothing have worked as expected. To conclude, the form is inside a <%= for user <- @users do %> which for me is not a big deal.
As mentioned here Form bindings — Phoenix LiveView v0.16.0 the form should be alright.

      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_view, "~> 0.16.0"},

Best Regards, ykostov

Have you defined a handle_event function to handle the add_match_result event?

If yes, can you post it?

This should be:

<.form let={f} for={@changeset} phx-change="validate" phx-submit="add_match_result">

The commas are not needed there and you have to use = to define phx-submit.

1 Like

those commas… thanks man :slight_smile:

No problem.
I think the commas would be ignored. The bigger problem was the phx-submit.

1 Like