Validation CakePHPform复选框验证错误未显示,但输入错误
我有一个带有必填字段的表单,其中一个字段是复选框。将显示所有验证错误,但复选框字段中没有错误。我安装了DebugKit插件,看到会有一个验证错误,但是没有显示消息Validation CakePHPform复选框验证错误未显示,但输入错误,validation,cakephp-2.1,Validation,Cakephp 2.1,我有一个带有必填字段的表单,其中一个字段是复选框。将显示所有验证错误,但复选框字段中没有错误。我安装了DebugKit插件,看到会有一个验证错误,但是没有显示消息 class Users extends AppModel { public $name = 'Users'; public $validate = array( 'email' => array( 'notEmpty' => array( 'rule' => 'not
class Users extends AppModel {
public $name = 'Users';
public $validate = array(
'email' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'Bitte geben Sie ihre Email-Adresse ein',
'allowEmpty' => false,
),
'isUnique' => array(
'rule' => 'isUnique',
'message' => 'Diese Adresse ist bereits angemeldet',
),
'email' => array(
'rule' => array('email',true),
'message' => 'Bitte geben Sie eine gültige Email-Adresse ein',
'allowEmpty' => false,
),
),
'terms' => array(
'rule' => array('comparison','!=',0),
'message' => 'Sie müssen unseren Nutzungsbedingungen zustimmen',
'allowEmpty' => false,
),
);
}
表格:
我尝试了$this->Form->error'terms';但当我调试这一行时,如果出现错误,只有
<div class="error_message"></div>
CakePHP是最新版本。从4个小时开始搜索帮助,但谷歌没有回答。有吗
问候
M.如果有人有同样的问题,我可以解决我的问题: 这个问题很特别。我试图用ISO8859-1保存我的文件,但它需要用UTF8保存。现在将显示错误消息
public function register() {
if ($this->Auth->user())
$this->redirect($this->referer('/'));
if ($this->request->is("post")) {
$this->Users->create();
$this->Users->set(Sanitize::clean($this->request->data));
#if ($this->Users->validates())
# die(debug($this->Users->validationErrors));
$this->_hash = $this->Auth->password($this->Users->data['Users']['email']);
$this->_password = $this->__randomString(8, 8);
$this->Users->set('password', $this->Auth->password($this->_password));
if ($this->Users->save()) {
$this->Users->id = $this->Users->getLastInsertID();
$this->_sendActivationMail();
$this->Session->setFlash('An die angegebene Emailadresse wurde soeben ein Aktivierungslink versendet.', 'default', array('class' => 'yellow'));
$this->redirect($this->referer());
} else {
$this->Session->setFlash('Ein Fehler ist aufgetreten', 'default', array('class' => 'red'));
}
}
}
<div class="error_message"></div>