Php Zend Form-我可以';t荷载元件';装饰器类文件
我有这样的表格:Php Zend Form-我可以';t荷载元件';装饰器类文件,php,forms,zend-framework,decorator,autoloader,Php,Forms,Zend Framework,Decorator,Autoloader,我有这样的表格: class Form_RegistrationForm extends Zend_Form { public function init() { [...] $username = new Zend_Form_Element_Text('username'); $email = new Zend_Form_Element_Text('email'); [...]
class Form_RegistrationForm extends Zend_Form {
public function init()
{
[...]
$username = new Zend_Form_Element_Text('username');
$email = new Zend_Form_Element_Text('email');
[...]
$elements = array($username, $email, [...]);
foreach($elements as $element) {
$element->addPrefixPath('Form_Decorator', 'Form/Decorator', 'decorator');
$element->addValidator('CustomErrors');
$this->AddElement($element);
}
}
}
我在/application/modules/Form/decorator/CustomErrors.php中找到了我的decorator。
我将decorator命名为:class Form\u decorator\u CustomErrors extensed Zend\u Form\u decorator\u Abstract
问题是Zend找不到我的装饰师。
我收到错误消息:注册表中找不到名为“CustomErrors”的插件;使用的路径:Zend\u验证\ Zend/Validate/
这有点奇怪,因为Zend似乎忽略了我定义的路径
我的appication.ini文件:
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view[] =
url.full = http://87.199.35.20/Kreskoweczki/bp/
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password =
resources.db.params.dbname = kreskoweczki
resources.db.params.charset = utf8
resources.db.params.prefix = kres_
;Mail transport settings
;mail.smpt - when false - sendmail is used
mail.smtp=true
mail.host=127.0.0.1
mail.smtpconfig.name=localhost
mail.smtpconfig.port=25
;mail.smtpconfig.auth = plain | login | crammd5
mail.smtpconfig.auth=
mail.smtpconfig.username=
mail.smtpconfig.password=
mail.from=no-reply@example.com
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
My index.php:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(
'../library/' . PATH_SEPARATOR .
'../application/modules/' . PATH_SEPARATOR .
'../application/' . PATH_SEPARATOR .
get_include_path()
);
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()->run();
//对于所有元素:
$form->addElementPrefixPath('My_Decorator', 'My/Decorator/', 'decorator');
//使用以下单个装饰器覆盖现有装饰器:
$element->setDecorators(array('CustomDecorator'));
$element->getPluginLoader('decorator')->GetPath()返回什么?在$element->addPrefixPath('Form_Decorator','Form/Decorator','Decorator')之后调用它代码>