在 cakephp 3.0 中,我想一起显示所有模态验证消息
in cakephp 3.0 i want to show all modal validation message together
在 cakephp 3.0 中,我想在视图表单上方一起显示所有模态验证消息。但它显示了各自的输入字段。请告诉我如何重新定位错误消息显示在 cake php 3.0.
上面
我成功地使用模板隐藏了表单中输入字段的错误显示,但无法获取模态错误消息。
我的tableclass如下
public function validationDefault(Validator $validator)
{
$validator
->add('id', 'valid', ['rule' => 'numeric'])
->allowEmpty('id', 'create');
$validator
->notEmpty('username','Username Must be provided')
->add('username', 'validFormat', [
'rule' => ['custom' , '/^[a-z0-9]{3,}$/i'],
'message'=>'Username must contain alphnumeric value and must be more that 3 characters']);
$validator
->add('email', 'valid', ['rule' => 'email'])
->requirePresence('email', 'create')
->notEmpty('email','Email Must be provided');
$validator
->requirePresence('password', 'create')
->notEmpty('password','Password must be provided');
$validator
->add('company', 'validFormat', [
'rule' => ['custom' , '/^[a-z0-9\s,]{3,}$/i'],
'message'=>'Company name can contain alphanumeric value only']);
$validator
->add('address', 'validFormat',[
'rule' => ['custom' , '/^[a-z0-9\s,]{3,}$/i'],
'message'=>'Address must be alphanumeric value.'])
->requirePresence('address','create')
->notEmpty('address','Address must be provided');
$validator
->requirePresence('country_id','create')
->notEmpty('country_id','Country name must be provided');
$validator
->add('city', 'valid',['rule' => ['custom' , '/^[a-z0-9\s,]{3,}$/i'],'message'=>'City can containalphanumeric value only.'])
->requirePresence('city','create')
->notEmpty('city','City must be provided');
$validator
->add('phone', 'valid',['rule' => ['custom' , '/^[0-9]{10,}$/i'],'message'=>'Phone must be atleast 10 characters.'])
->requirePresence('phone','create')
->notEmpty('phone','Address must be provided');
return $validator;
}
您尝试过调试实体吗?然后你会注意到错误。 $entity->errors();
尝试教程:http://book.cakephp.org/3.0/en/tutorials-and-examples.html
你本可以自己用谷歌搜索这个
在 cakephp 3.0 中,我想在视图表单上方一起显示所有模态验证消息。但它显示了各自的输入字段。请告诉我如何重新定位错误消息显示在 cake php 3.0.
上面我成功地使用模板隐藏了表单中输入字段的错误显示,但无法获取模态错误消息。
我的tableclass如下
public function validationDefault(Validator $validator)
{
$validator
->add('id', 'valid', ['rule' => 'numeric'])
->allowEmpty('id', 'create');
$validator
->notEmpty('username','Username Must be provided')
->add('username', 'validFormat', [
'rule' => ['custom' , '/^[a-z0-9]{3,}$/i'],
'message'=>'Username must contain alphnumeric value and must be more that 3 characters']);
$validator
->add('email', 'valid', ['rule' => 'email'])
->requirePresence('email', 'create')
->notEmpty('email','Email Must be provided');
$validator
->requirePresence('password', 'create')
->notEmpty('password','Password must be provided');
$validator
->add('company', 'validFormat', [
'rule' => ['custom' , '/^[a-z0-9\s,]{3,}$/i'],
'message'=>'Company name can contain alphanumeric value only']);
$validator
->add('address', 'validFormat',[
'rule' => ['custom' , '/^[a-z0-9\s,]{3,}$/i'],
'message'=>'Address must be alphanumeric value.'])
->requirePresence('address','create')
->notEmpty('address','Address must be provided');
$validator
->requirePresence('country_id','create')
->notEmpty('country_id','Country name must be provided');
$validator
->add('city', 'valid',['rule' => ['custom' , '/^[a-z0-9\s,]{3,}$/i'],'message'=>'City can containalphanumeric value only.'])
->requirePresence('city','create')
->notEmpty('city','City must be provided');
$validator
->add('phone', 'valid',['rule' => ['custom' , '/^[0-9]{10,}$/i'],'message'=>'Phone must be atleast 10 characters.'])
->requirePresence('phone','create')
->notEmpty('phone','Address must be provided');
return $validator;
}
您尝试过调试实体吗?然后你会注意到错误。 $entity->errors();
尝试教程:http://book.cakephp.org/3.0/en/tutorials-and-examples.html
你本可以自己用谷歌搜索这个