开发者

Zend framework: Forms in modules

What I want to do:

Create a number of modules with the forms folder inside them.

What I did:

Create a bootstrapper inside the module and added an _initAutoload function with the specific module name as namespace.

For instance, an admin module with the following bootstrapper:

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{

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

}

My question is:

Is this t开发者_开发技巧he correct way of doing what I want? - I tried it without having the admin bootstrapper, but it couldn't find my form, until I added the bootstrapper.

Cheers

Chris


The autoloader is automatically set up for each module bootstrap. You don't need to configure it manually.

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap {}

is all you need.

Then put your forms in /application/modules/admin/forms/.

Admin_Form_Myform extends Zend_Form {...}

For your custom resources, customize resourceAutoloader:

   class Admin_Bootstrap extends Zend_Application_Module_Bootstrap 
   {
        public function _initAuloload() 
        {
             $resourceLoader = $this->_resourceAuloloader;
             // var_dump($resourceLoader);
        }
   }


Remember to add also in your apllication.ini

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

resources.modules = ""

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜