Page 1 of 1

Please help me, Zendians!

Posted: Wed Mar 04, 2009 6:32 am
by robincanaday
For some reason, when I try to instantiate class inside a controller action, I get this message:

Code: Select all

Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in C:\xampp\files\library\Zend\Controller\Dispatcher\Standard.php:241 Stack trace: #0 C:\xampp\files\library\Zend\Controller\Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 C:\xampp\files\application\index.php(65): Zend_Controller_Front->dispatch() #2 C:\xampp\files\public\index.php(3): require_once('C:\xampp\files\...') #3 {main} thrown in C:\xampp\files\library\Zend\Controller\Dispatcher\Standard.php on line 241
My Controller looks like this:

Code: Select all

 
class IndexController extends Zend_Controller_Action {
 
public function indexAction() {
 
$this->view->title = 'Random Form';
 
$form = new Zend_Form();
$form->addElement(new Zend_Form_Element_Text());
 
$this->view->form = $form;
 
}
 
}
My view looks like this:

Code: Select all

 
<h1><? echo $this->title; ?></h1>
<? echo $this->form; ?>
 

It works just fine when I don't try to use any objects in the action. I even created a dummy class just to make sure I'm not using Zend_Form all wrong. What am I doing wrong here?

Re: Please help me, Zendians!

Posted: Wed Mar 04, 2009 4:52 pm
by Weirdan
Zend_Form::addElement() throws an exception because it does not receive element name to add (see examples here for proper way to add elements), front controller catches this exception, ErrorHandler plugin notices that and tries to redirect to error controller, which you have not created (see documentation about ErrorHandler plugin here).

Re: Please help me, Zendians!

Posted: Thu Mar 05, 2009 4:36 am
by robincanaday
That worked, thanks :)
I must have been too tired when I made my dummy class to make sure it wasn't just me messing up Zend_Form...

Yeah, I haven't gotten around to setting up an Error controller.