Please help me, Zendians!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
robincanaday
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2008 12:25 am
Location: Portland Oregon USA

Please help me, Zendians!

Post 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?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Please help me, Zendians!

Post 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).
robincanaday
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2008 12:25 am
Location: Portland Oregon USA

Re: Please help me, Zendians!

Post 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.
Post Reply