1
我有某種形式是這樣的:Zend的形式 - 我無法加載元素的裝飾類文件
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
。 我已經命名裝飾者:class Form_Decorator_CustomErrors extends Zend_Form_Decorator_Abstract
問題是,Zend無法找到我的裝飾器。 我收到錯誤消息:在註冊表中找不到名爲'CustomErrors'的插件;使用的路徑:Zend_Validate_:Zend/Validate/
這是一個litte werid,因爲它看起來像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=
[email protected]
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
我的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();
什麼'$ element-> getPluginLoader('decorator') - > getPaths()'返回?在'$ element-> addPrefixPath('Form_Decorator','Form/Decorator','decorator');'後面調用它' – Michael