|
How to populate a select form element from a different module/controller/mo: msg#00116php.zend.framework.mvc
Hi All, I know some of this (MVC) stuff has been discussed before, but I'm still curious and looking for guidance, advice, clarification or perhaps a best practice for the following: a. I have a module (controller, model, views) for creating and managing static pages and I also have a separate controller and model for managing languages. b. Using a form (Zend_Form -> select element, dropdown list), a user can can set the language for each static page. The form itself is instantiated inside the PageController. My specific problem: How and where (controller/model/view helper) would I fetch the language (array) data, located in the Language model with access to the languages database table, for the select element/dropdown list in the Page form (located in the PageController)? Solutions I can think of: 1. Create a query in the Page Model, that fetches the languages from the other table in the database. Easiest, but what if the language table changes? Then I need to update the query in both the Page model and Language model (not very DRY), instead of only the Language model. 2. Require or include the Language model in the Page Model, retrieve the language data and return the data to the PageController that sets it the Page form. Wow! 3. Require or include the Language model in the PageController, retrieve the form element in the page form and using the language model set the options on the select element. 4. Anymore solutions exist? My general problem: Can models access other models directly, or should there always be a controller between them? Which creates a different problem when Controllers need to connect to other Controllers to get to the model data. I'm actually quite confused to see that a View (helper) can have read access to a model, controllers setup and access models, but also the possibility that models can access other models as well. Regards, TJ. -- View this message in context: http://www.nabble.com/How-to-populate-a-select-form-element-from-a-different-module-controller-model--tp18566030p18566030.html Sent from the Zend MVC mailing list archive at Nabble.com. |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Re: Zend_Test, PHPUnit & option --coverage-html: 00116, Matthew Weier O'Phinney |
|---|---|
| Next by Date: | Re: How to populate a select form element from a different module/controller/model?: 00116, Bryce Lohr |
| Previous by Thread: | Zend_Test, PHPUnit & option --coverage-htmli: 00116, mikaelkael |
| Next by Thread: | Re: How to populate a select form element from a different module/controller/model?: 00116, Bryce Lohr |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |