2009年3月29日星期日

[fw-mvc] Method addMultiOptions does not exist ?

Hey all, I'm trying to populate my select box with data from my db, however, I'm having no success...
 
I get the error: Method addMultiOptions does not exist
 
... snip
 
    /**
     * Setup our vars
     */
    protected $_model;
 
    public function indexAction()
    {
     $model = $this->_getModel();
     $form = $this->_getServiceReportForm();
 
  foreach($model->fetchEntriesOrdered('company_name') as $c)
        {
         $form->getElement('company')->addMultiOptions(array(
   $c['id'] => $c['company_name']
   ));
        }
 
        if ($this->_request->isPost()) {
 
            if ($form->isValid($_POST)) {
             
                /*
                 * Process data
                 */
 
            } else {
             
                /*
                 * Data not valid
                 */             
               $form->populate($this->getRequest()->isPost());
            }
 
        } else {
 
           $this->view->form = $form;
        }
    }
... end snip
 
 
my form has this (extending Zend_Form)
 
        $this->addElement('select', 'company', array(
     'label'   => 'Company:',
     'required'  => true,
  ));
 
.......
 
My Model:
    public function fetchEntriesOrdered($order)
    {
     return $this->getTable()->fetchAll(null, $order)->toArray();
    }

没有评论: