Hi I assume that you are including sername and password as hidden fields because they are required in your validation array - but rather than include them as hidden fields it might be better to create different validate arrays in your model e.g.
var $validate = array( 'somefield' => array('notempty'), 'someotherfield' => array('notempty'), 'password' => array('notempty') ); var $validate_edit = array( 'somefield' => array('notempty'), 'someotherfield' => array('notempty') ); Then in your controller you can just choose which validation array you want to apply, therefore you won't have to include any hidden fields unnecessarily. e.g. $this->{$this->modelClass}->validate = $this->{$this->modelClass}- >validate_edit; You could alternatively use the 'on' option in your validation array (see http://book.cakephp.org/view/127/One-Rule-Per-Field) var $validate = array( 'fieldName1' => array( 'rule' => 'ruleName', // or: array('ruleName', 'param1', 'param2' ...) 'required' => true, 'allowEmpty' => false, 'on' => 'create', // or: 'update' 'message' => 'Your Error Message' ) ) I prefer to create multiple validation arrays as it is really easy to read and keeps things nice and clear. John On May 5, 1:11 pm, paulos nikolo <paulitosthe...@gmail.com> wrote: > Well i found the solution...i put sername and password as hidden so that > there are enough data for update! > Thx again m8! > > 2009/5/5 paulos nikolo <paulitosthe...@gmail.com> > > > Thx for the hint Jonh.Well when i try to change status from 1 to 0 > > (checkbox unchecked) here is what debug prints: > > > Array > > ( > > [User] => Array > > ( > > [status] => 0 > > > [id] => 54 > > ) > > > ) > > > Which it seems ok to me...i cant understand what's going on.The status has > > been changed but it cant be saved. > > > 2009/5/5 John Andersen <j.andersen...@gmail.com> > > >> Try to put a debug statement into the controller in the change_status > >> method, to see that it is getting invoked! > >> For example "debug($this->data);" > >> Enjoy, > >> John > > >> On May 5, 1:47 pm, Paulos23 <paulitosthe...@gmail.com> wrote: > >> > Hello people, > >> > I am facing a really weird problem with an issue.I have a field in > >> > users table which is called status.I have set it to tinyint(1) not > >> > null default '1',which means user status is active.Now when i want to > >> > change his status to inactive--> '0' > >> > i use a checkbox as it is more appropriate,so if i leave it unchecked > >> > User.status become inactive.The weird thing is that when i do that the > >> > action in users_controller which is called change_status does > >> > NOTHING.No errors,no saving new data...just nothing.I wonder if there > >> > is a bug with checkbox button or something else. > >> > Here i put my code..Plz if you have any ideas i 'd be glad. > > >> > Thx in advance! > > >> > views/users/change_status.ctp > > >> > <h1>User Status Change</h1> > > >> > <?php > >> > echo $form->create('User', array('action' => 'change_status')); > > >> > echo $form->input('User.status', array ('type' => > >> > 'checkbox','label'=> 'Active')); > > >> > echo'<p>Set the user account as active or inactive </p>'; > >> > echo $form->input('id', array('type'=>'hidden')); > >> > echo $form->end('Save'); > >> > ?> > > >> > controllers/users_controller > > >> > function change_status($id=null){ > >> > //$this->User->id = $id; > >> > if (empty($this->data)) { > >> > $this->data = $this->User->read(null, $id); > >> > } else { > >> > if ($this->User->save($this->data)) { > >> > $this->Session->setflash('User status has been > >> updated!'); > >> > $this->redirect('/users'); > >> > } > >> > } > >> > } > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---