我在本地工作站(Windows)上安装了zend framework 1.11.11的新副本。对于我的管理模块,我在/application/modules/admin/models/Form/Login.php下创建了“Login.php”表单。我还在Bootstrap.php中设置了自动加载器,如
protected function _initAutoloader()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('My_');
new Zend_Application_Module_Autoloader(array(
'basePath' => APPLICATION_PATH,
'namespace' => 'Default')
);
$loader = new Zend_Loader_Autoloader_Resource(array(
'basePath' => APPLICATION_PATH.'/models/',
'namespace' => '')
);
$loader->addResourceType('forms', 'Form/', 'Form');
return $autoloader;
}
在admin模块的IndexController.php文件的loginAction()方法中,我正在使用
$form = new Admin_Model_Form_Login();
但是低于错误: -
致命错误:找不到“Admin_Model_Form_Login”类 C:\瓦帕\ WWW \ ZTEST \应用\模块\管理员\控制器\ IndexController.php
以下是Login.php的代码
class Admin_Model_Form_Login extends Zend_Form
{
public function init()
{
parent::init();
$this->setAction('/admin/index/login')->setMethod('post');
$account = new Zend_Form_Element_Text('account');
$account->setLabel('Username')->setRequired(true);
$account->setOrder(1);
$this->addElement($account);
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password');
$password->setOrder(2);
$this->addElement($password);
$submit = new Zend_Form_Element_Submit('login');
$submit->setLabel('Login');
$submit->setOrder(3);
$this->addElement($submit);
}
}
答案 0 :(得分:5)
您是否已将Bootstrap.php文件添加到模块的路径中?
该文件应该在/application/modules/admin/Bootstrap.php中找到
与此类似:
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
//Can be left blank
}