You short-circuit the MVC model offered by Zend Framework whereas you should use a Zend_Form for your HTML form element in a controller and populate it with your model, then you affect it to the view. A really quick example :
*MyForm.php* function init() { $faculty = new Zend_Form_Element_Select('faculty'); $faculty->addMultiOPtions("", '-- Faculty --'); $this->addElement($faculty); } *MyController.php* function sampleAction() { // Data $model = new Material_Model_Faculty(); $faculties = $model->getAll(); unset($model); // Form $form = new MyForm(); foreach ($faculties as $faculty) { $form->getElement('faculty')->addMultiOptions($this->url(array("faculty" => $faculty->id), "materials"), $faculty->name); } $this->view->form = $form; return; } *MyController/sample.phtml* <?php print($this->form); ?> or for more flexibility <?php print($this->form->getElement('faculty')); ?> Hope sincerely this will help you On Mon, Apr 6, 2009 at 10:43 AM, Marko Korhonen < marko.korho...@datafisher.com> wrote: > > Hi, > > I have made my model system as: > Model, Model_DbTable, Model_DbTable_Row etc... > > I have always declared by models in controller, but MVC seems > to "allow" View to command models also? > I also try to live by the "Fat models, thin controllers" rule... > > So I made following: > > <select name="faculty" id="faculty"> > > <option value="">-- Filter by Faculty --</option> > <?php $model = new Material_Model_Faculty(); foreach > ($model->getAll() as > $faculty): ?> > <option value="<?= $this->url(array("faculty" => $faculty->id), > "materials") ?>"><?= $faculty->name ?></option> > <?php endforeach; ?> > > </select> > > > > This is kinda "religious" question, I know... =) > But this approach gives me very flexible developing... > > br, Marko > -- > View this message in context: > http://www.nabble.com/MVC---Model-in-View-tp22904523p22904523.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- Thomas VEQUAUD http://thomas.vequaud.free.fr/ Expert EPITECH en Ingénierie Informatique Tél : +33(0)6.50.39.28.10 Fax: +33(0)9.58.46.10.07