I’m using Phoenix 1.4 and having trouble with forms. For details, see:
Help?
I’m using Phoenix 1.4 and having trouble with forms. For details, see:
Help?
Can you please paste your router.ex
file?
It looks like you’ll need to replace Routes.page_path
in your form_for
tag with Routes.text_path
As @chensan said, your router file or mix phx.routes will help you identify the correct route to use.
At present you’re trying to use the find_show function from the PageController, but I’m guessing that you don’t have one of those and instead have a TextController?
As requested, I’ve added a copy of the router.ex
file to the gist (linked again below). I have a module named TextController, but that isn’t used here. The find_show
function lives in resources_controller.ex
.
Nothing in your router suggests you would be able to call Routes.page_path/2
. The functions in the Routes
module are generated from the paths you define in your routes. Because you don’t have a PageController
assigned to any path, Routes.page_path/2
will not exist.
Based on the line post "/resources/find", ResourcesController, :find_show
in your router, you will need to modify the form as follows:
<%= form_for @conn, Routes.resources_path(@conn, :find_show), fn _f -> %>
...
<% end %>
Thanks; that seems to be working! FWIW, I had no idea that the name page_path
was magically related to the name PageController
. I’d love to have pointers to documentation on this relationship.
Indeed it is, but I somehow didn’t catch the implications the first time I read it. Thanks again!
If you want to see a list of *_path
s for all of the routes, you can run mix phx.routes
from the root of the Phoenix app.