无法访问模块控制器中的模块表单 [英] Unable to access module forms in module controller
问题描述
我有一个测试模块.在测试模块中,我在Forms文件夹中有一个Form.
I have a test module. In test module I have a Form in forms folder.
myproject/application/modules/test/forms/TestForm.php
class Test_Form_TestForm extends Zend_Form {
//form elements
}
myproject/application/modules/test/controllers/TestController.php
class Test_TestController extends Zend_Controller_Action {
public function indexAction() {
$this->view->form = new Test_Form_TestForm(); // this is generating error
}
} // end class
控制器中的窗体初始化生成以下错误:
Form initialization in controller is generating following error:
Fatal error: Class 'Test_Form_TestForm' not found in C:\wamp\www\student\application\modules\notification\controllers\NotificationController.php on line 16
如何在控制器中访问此表单.相同类型的案例与默认控制器一起使用.我知道我必须使用Form_指示器在引导程序中注册我的模块,但不知道确切的语法.
How to make this form accessable in controller. Same type of case is working with default controller. I know I have to register my module in bootstrap with Form_ indicator but dont know exact syntax.
推荐答案
您还可以在一个Bootstrap文件中的单独函数中初始化多个模块,例如:
You can also initialize multiple modules in a separate function in one Bootstrap file like:
protected function _initAutoloaders() {
$test_loader = new Zend_Application_Module_Autoloader( array( 'namespace' => 'Test',
'basePath' => APPLICATION_PATH . '/modules/test'
));
$mynew_loader = new Zend_Application_Module_Autoloader( array( 'namespace' => 'Mynew',
'basePath' => APPLICATION_PATH . '/modules/mynew'
));
}
这篇关于无法访问模块控制器中的模块表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!