Take the 2-minute tour ×

I have tried setting up a zend site with the following directory structure :


Then in my IndexController.php I have the following

public function contactMeAction() {

    $request = $this->getRequest();
    $form    = new Form_Testform();

        if ($form->isValid($request->getPost())) {

//process stuff


    $this->view->form = $form;


in the file Testform.php I have

class Form_Testform extends Zend_Form { public function init() { ......etc

But i'm getting the following error :

Fatal error: Class 'Form_Testform' not found in /home/websites/test.local/public_html/prototype/application/modules/default/controllers/IndexController.php on line 22

Call Stack: 0.0004 325228 1. {main}() /home/websites/test.local/public_html/prototype/public/index.php:0 0.1742 5351472 2. Zend_Application->run() /home/websites/test.local/public_html/prototype/public/index.php:28 0.1742 5351472 3. Zend_Application_Bootstrap_Bootstrap->run() /opt/ZendFramework-1.10.7/library/Zend/Application.php:366 0.1745 5351708 4. Zend_Controller_Front->dispatch() /opt/ZendFramework-1.10.7/library/Zend/Application/Bootstrap/Bootstrap.php:97 0.1872 5707240 5. Zend_Controller_Dispatcher_Standard->dispatch() /opt/ZendFramework-1.10.7/library/Zend/Controller/Front.php:954 0.2026 6016200 6. Zend_Controller_Action->dispatch() /opt/ZendFramework-1.10.7/library/Zend/Controller/Dispatcher/Standard.php:295 0.2029 6020692 7. IndexController->contactMeAction() /opt/ZendFramework-1.10.7/library/Zend/Controller/Action.php:513

Where am I going wrong?

share|improve this question

3 Answers 3

Basically ZF is not finding the form where it expects it to be. I think you need to have the form in application/forms, not in application/modules/default/forms like you do.

Then have it as:

Application_Form_Testform extends Zend_Form

instead of

Form_Testform extends Zend_Form


So in application/forms you have the file Testform.php That file looks like:

class Application_Form_Testform extends Zend_Form { 
// form code

In your controller you have (note the naming of the action... contactmeAction, not contactMeAction):

public function contactmeAction {
    $form = new Application_Form_Testform();
    $this->view->form = $form;

Then in your view contactme.phtml:

echo $this->form;

This should work. If it doesn't I would check spelling, capitalization in your action name and make sure things are in the correct path.

share|improve this answer
I tried that, but it didn't work. –  Paul Oct 1 '10 at 18:29
See my edit. That should fix it (note the case of the name of your action). –  Stuart Oct 3 '10 at 2:56
I'm getting Fatal error: Class 'Application_Form_Testform' not found, is there a way to display on screen where it's trying to look? –  Paul Oct 3 '10 at 10:47

This is an issue of getting the following things all aligned/consistent:

  1. namespacing
  2. class naming conventions
  3. class file location

If you wish to put your form in the folder application/modules/default/forms, then name the class Default_Form_Testform.

share|improve this answer
Putting it in that folder and renaming it didn't work for me unfortunately –  Paul Oct 1 '10 at 18:29
Are you declaring/setting a different appnamespace in either a 1. configs/application.ini or 2. a Bootstrap::_initXXX() method? –  David Weinraub Oct 2 '10 at 0:10

Check names/namespaces as gaoshan88 says (must be "class Application_Form_Testform extends Zend_Form" and "$form = new Application_Form_Testform()"; )

Check that your application/configs/application.ini contains these lines:

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.defaultModule = "default"
resources.modules[] = ""

Finally create an empty Bootstrap.php file and put it in application/modules/default/ directory.

share|improve this answer

Your Answer


