Search code examples
zend-frameworkzend-config

zend_form config problem


I have a structure like follows:

/application
.....
--/modules
----/structure
------/controllers
--------/indexController.php
------/forms
--------/Department.php //here class Structure_Form_Department extends Zend_Form

in indexController.php

...
public function saveAction()
    {
        $request = $this->getRequest();
        $form = new Structure_Form_Department();//<-- error
....
}

and i get error

Fatal error: Class 'Structure_Form_Department' not found

when try to zf enable form module - receive :

An Error Has Occurred                         
 This project already has forms enabled.

i think this is a config-like problem... but do not understand what i need to do...

EDIT 1

found good solution here

but for some way zend starts repeat executing _init... functions from default bootstrap.php....


Solution

  • I was also facing a similar problem few months ago and I got the solution by writing following code :

    In application.ini

    autoloadernamespaces[] = "Structure_"
    

    In Bootstrap.php

    protected function _initAutoload()
        {
            $autoloader=new Zend_Application_Module_Autoloader(array(
                    'namespace' => 'Structure',
                    'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'Structure'
                ));
        }
    

    And at the index.php

    set_include_path(implode(PATH_SEPARATOR, array(
        realpath(APPLICATION_PATH . '/../library'),
        realpath(APPLICATION_PATH),
        get_include_path(),
    )));
    

    Please let me know if it doesn't works.....