Hi,
in my app_controller I put the function:
function unbindValidation($type, $fields, $require=false){
if ($type === 'remove'){
$this->validate = array_diff_key($this->validate,
array_flip($fields));
}else if ($type === 'keep'){
$this->validate = array_intersect_key($this->validate,
array_flip($fields));
}
if ($require === true){
foreach ($this->validate as $field=>$rules){
if (is_array($rules)){
$rule = key($rules);
$this->validate[$field][$rule]['required'] = true;
} else{
$ruleName = (ctype_alpha($rules)) ? $rules :
'required';
$this->validate[$field] =
array($ruleName=>array('rule'=>$rules,'required'=>true));
}
}
}
}
in my user.php model I added an array
var $validate = array(.....
with all my rules, which are working fine!
No I want to use the unbindValidation function within my edit function
form the users_controller:
function edit($id = NULL){
$this->User->unbindValidation('keep', array('usr_vorname',
'usr_nachname'), true);
if(empty($this->data)){
$this->data = $this->User->read(NULL, $id);
$this->set('user', $this->User->read(NULL, $id));
}else{
if($this->User->save($this->data)){
$this->Session->setFlash('Alle Änderungen wurden
erfolgreich übernommen');
$this->redirect(array('action'=>'index'));
}
}
}
But when I submit the form, I get the following message:
Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'unbindValidation' at line 1 [CORE\cake\libs
\model\datasources\dbo_source.php, line 684]
Why is that?
What do I have wrong?
Please advise!!
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php