开发者

Zend: Unable to access form in controller

First I created a project using Zend_Tool. Then created a controller AuthenticationController in default module.

Created Form in projectfolder/application/forms/Login.php

class Forms_Login extends Zend_Form {
    public function _construct() {
        // add ele开发者_如何转开发ments
    }
}

Accessing Form in myproject/application/controllers/AuthenticationController.php

public function loginAction() {
   $this->view->form = new Form_Login();
}

I am getting following error:

Fatal error: Class 'Application_Forms_Login' not found in /var/www/student/application/controllers/AuthenticationController.php on line 19

How can I access it with same form class name without including this file in AuthenticationController??

May be I have to tell zend in Bootstrap.php about this but I wan unable to find a sample code.

Thanks


you should declare them in your bootstrap.php file like so:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoload()
    {
        $autoLoader=Zend_Loader_Autoloader::getInstance();
        $resourceLoader=new Zend_Loader_Autoloader_Resource(array(
            'basePath'=>APPLICATION_PATH,
            'namespace'=>'',
            'resourceTypes'=>array(
                'form'=>array(
                    'path'=>'forms/',
                    'namespace'=>'Forms_'
                )                
            )

            ));


        $autoLoader->pushAutoloader($resourceLoader);




    }


}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜