MVC 'best practice' for displaying data
Posted: Wed Dec 01, 2010 2:51 pm
So this is a pretty trivial question and it's possible I'm just overthinking things, but here goes:
I've got a form for users to get rates calling from City A to City B. The controller validates the $_POST information, sends it off to the model to fetch the required data from the database, gets the results from the model and then sends them back to the view to be displayed. So far, that's my understanding of how things are 'meant' to work. Now, when displaying the results, I want to display either Calling from Country; Calling from City, Country; or Calling from City, State as the case warrants. City, State, and Country are all columns in the database, so the model returns them all in the result array. My question, then, is whether the logic to determine which combination of columns to display belongs in the controller or the view.
On the one hand, I think it's purely a question of display and belongs in the view. On the other, I think it's maybe better for the view to expect one value to display and for the controller to decide what it contains. I realize, of course, that either will get the job done but, as I'm still relatively new to the whole MVC approach, I figured I'd ask if there was an accepted 'correct' way of doing this.
Thanks for your help.
I've got a form for users to get rates calling from City A to City B. The controller validates the $_POST information, sends it off to the model to fetch the required data from the database, gets the results from the model and then sends them back to the view to be displayed. So far, that's my understanding of how things are 'meant' to work. Now, when displaying the results, I want to display either Calling from Country; Calling from City, Country; or Calling from City, State as the case warrants. City, State, and Country are all columns in the database, so the model returns them all in the result array. My question, then, is whether the logic to determine which combination of columns to display belongs in the controller or the view.
On the one hand, I think it's purely a question of display and belongs in the view. On the other, I think it's maybe better for the view to expect one value to display and for the controller to decide what it contains. I realize, of course, that either will get the job done but, as I'm still relatively new to the whole MVC approach, I figured I'd ask if there was an accepted 'correct' way of doing this.
Thanks for your help.