-1
in cakephp 3.0我想在視圖窗體上方顯示所有的模態驗證信息。但它與各自的輸入字段一起顯示。請讓我知道我可以重新定位上面的錯誤消息顯示在蛋糕php 3.0中。in cakephp 3.0我想在一起顯示所有的模態驗證信息
我成功地通過使用模板,但無法獲取模態錯誤消息,以隱藏窗體中輸入字段的錯誤顯示。
我的表類是如下
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;
}
你試着調試實體?那麼你會注意到錯誤。 $實體 - >錯誤(); –
感謝alex工作,我正在做其他事情。 Plz將cakephp 3.0的一些教程網站引薦給我 –