What are the basics of working with forms?

Hello, can anyone point me to the right direction? I didn’t find anything useful in the documentation of phoenix. I’d like to work with forms, for example lets start with something simple, the form has two inputs, each one is for a number, and there is a submit button, upon pressing the submit button I want to return the two numbers added. How would I accomplish this?

https://hexdocs.pm/phoenix_html/3.0.4/Phoenix.HTML.Form.html

1 Like

The thing is, I read that and did not understand it…

So I would have a form, and have it send a post request to a set path in my router… And I’d a function within the controller that would take in the information and return the output yeah? (I assume that this is the part where I uncomment “params”)

Yes, that’s the high-level overview of how that works.

The browser sends the form data to a URL, the Phoenix router dispatches the request to a controller/action; the function runs the logic and at the end probably makes a call to render to render the resulting HTML.

2 Likes