Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>What purpose does a 1:1 relationship between controller and view serve?</p> </blockquote> <p>There is no need for a strict 1:1 rule if the view can be applied in multiple workflow contexts / controllers / models. Keeping a view and controller separate, even if they are only used together and can be merged, is a best practice for a clear separation of responsibilities. It also makes it easier to swap and share views later.</p> <blockquote> <p>Where should the template file be selected?</p> </blockquote> <p>In your case you have a View class, so it should be defined there. In some systems the template <em>is</em> the view and is often selected in the controller or configuration files.</p> <blockquote> <p>How does the view get to know about errors in the model? How does the view get to know about successful or unsuccessful command/action in controller?</p> </blockquote> <p>In some architectures the models return their issues to the controller during updates or any other actions. In the controller I usually add any problems to a user message stack. Then in the view I output those messages to the user.</p> <blockquote> <p>How do I change view when there is an error? Or how do I properly do my routing for the cases when a user state changes.</p> </blockquote> <p>This I've seen handled in quite a few different ways. The most robust solution is for your controller to pass the next workflow steps to the view. The view should basically stay as agnostic as possible to any business logic.</p> <p>Any example code would be too long and elaborate for SO. I would start with good MVC framework tutorials:</p> <ul> <li><a href="http://laravel.com/docs/validation" rel="nofollow">Laravel validation rules</a></li> <li><a href="http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html" rel="nofollow">Codeigniter form validation</a></li> <li><a href="http://symfony.com/doc/current/book/validation.html" rel="nofollow">Symfony validation</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload