我在本地工作站 (Windows) 上安装了一份全新的 zend 框架 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;
}
在我的管理模块的 IndexController.php 文件的 loginAction() 方法上,我正在使用
$form = new Admin_Model_Form_Login();
但是出现以下错误:-
致命错误:在 C:\wamp\www\ztest\application\modules\admin\controllers\IndexController.php 中找不到类 'Admin_Model_Form_Login'
这是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);
}
}