You can also you Phoenix.HTML.Tag.form_tag/3 to create forms, but be aware that you will not be able to use functions from Phoenix.HTML.Form, like the text_input/3 in this case, you will need to build your input tags manually (which normally is not a big problem if you don’t have a model linked to the form).
I’m quite new to this. Not even an ex Ruby on Rails programmer. This seems to be exactly what I’m looking for, but I’m stumped by one detail. These examples all have an action listed, i.e auth_path(@conn, :signin) in kostonstyle’s solution, session_path(@conn, :create) in adides’ suggestion,… So my noob question is, where does this action function live? I’m trying to understand how this statement “:create would refer to the create action…” relates to the session_path action.
I can understand that I need a create() in the controller, but then in which file in my code does the session_path() code belong in? Thanks!
I stumbled upon this myself.The session_path is automatically generated for you and not actually defined as such. (I grepped the code in all sorts of different ways trying to find it)
It is the resource macros in the router module that creates these helpers for you.
Thanks! I added this to the router:
post “/users/:userName”, UserController, :update, as: :update_page
And now the only place I see update_page_path is:
ganymede:phoenixDSK mbk$ grep -r “update_page_path” *
Binary file _build/dev/lib/phoenixDSK/ebin/Elixir.PhoenixDSK.Router.Helpers.beam
Expected? If so, that means that I reference it in the form but it’s not code to be modified… Thanks again!
Great help! A few things you helped me clarify. 1) The fact that these helper functions produce a string, which is what form_for is looking for in the 2nd position over. I’d not caught that in the docs, even though I clearly see it now! 2) The string is the path describing the action. 3) Finally, thanks for the references to the documentation. This statement in the Router doc “Helpers are automatically generated based on the controller name.” finally made sense. If a controller is named DogcatController, then the helper would be dogcat_path(), where I kept looking at the paths in the router and thinking they determined the name of the helper. Thanks again!