【发布时间】:2011-11-07 11:52:54
【问题描述】:
我有一个模型,我想在其中翻译表单验证错误。所以我把$validate的填充移到了构造函数中:
function __construct() {
$this->validate = array(
'url' => array(
'url' => array(
'rule' => array('url'),
'message' => __('Enter a valid URL', true),
),
),
'revisit' => array(
'numeric' => array(
'rule' => array('numeric'),
'allowEmpty' => true,
),
),
'reading_list' => array(
'boolean' => array(
'rule' => array('boolean'),
),
),
);
}
每当我打开任何页面时,都会出现以下错误:
Fatal error: Call to a member function trigger() on a non-object in /home/mu/Branches/cakemarks/cake/libs/model/model.php on line 2106
Call Stack:
0.0005 347980 1. {main}() /home/mu/Branches/cakemarks/app/webroot/index.php:0
0.0548 3580716 2. Dispatcher->dispatch() /home/mu/Branches/cakemarks/app/webroot/index.php:83
0.0597 3735300 3. Dispatcher->_invoke() /home/mu/Branches/cakemarks/cake/dispatcher.php:171
0.1451 7428100 4. call_user_func_array() /home/mu/Branches/cakemarks/cake/dispatcher.php:204
0.1451 7428336 5. BookmarksController->startscreen() /home/mu/Branches/cakemarks/cake/dispatcher.php:0
0.1451 7429132 6. Model->find() /home/mu/Branches/cakemarks/app/controllers/bookmarks_controller.php:100
在我在那里使用__() 函数之前,我可以在字段外使用$validate,它运行良好。
我怎样才能在那里输入验证消息?
【问题讨论】:
标签: php cakephp internationalization