I'm still somewhat confused by how MVC is supposed to work.
Lets say I have a website selling widgets. I have a listing page, /widgets/list
and a product page /widgets/product/123
.
Both of these can use the widget
controller and call the list
and product
methods - simple enough so far. Lets say I also have several other controllers for various things.
Now I add a newsletter signup box into my header - i.e. on every page of the site.
How is this going to work? I get the idea that it should submit to /newsletter/signup
But what happens if there's an error (say you didn't fill in your email address correctly)? It should show whatever page you were on (e.g. /widgets/list
) but the newsletter
controller needs to run. The widget
controller doesn't know about the newsletter
controller so I can't put the code there... How is this supposed to work?
Edit: No AJAX please - I can understand that more easily. Consider this the fallback when javascript is disabled.
Edit 2: Any examples or tutorials covering this kind of thing would be much appreciated
Edit 3: Is it allowable for a view to call an action? For example the header might call Newsletter->index()