So I’m trying to build my first phoenix website, I’ve been going through various tutorials and the Programming Phoenix 1.4 book and they all seem to be teaching the concept that each Context has it’s own model (Schema), with a controller, and corresponding templates with the model’s form, which is great and makes a ton of sense to me.
However, when it comes time to applying what I’ve been learning, I’m completely lost. I’m trying to figure out how to add a simple email sign-up input on the homepage. I created the homepage by altering the templates/page/index.html.eex and that works great. But now when it’s time to add the email sign-up form, I’m floundering.
I created a lead schema with only an email address field. Now how do I add an email sign-up form on the homepage where the email address gets stored in the database? I started to build out a controller for the lead schema, but that doesn’t seem right to me because the controllers usually map the schema to the templates, but in this case, the only template I want it to map to is the index page. So how do I add a form to the homepage and then pass the data from that form to the database (using the controller for the lead I imagine, but I don’t know how)?
I feel like I’m making this way too difficult than it should be. Any pointers or guidance that can be provided would be greatly appreciated.