Ok Brian so i ll use tinyint.But after that i make default 1 for active and when i wanr to change it to inactive nothing happen.I am using a checkbox coz i think it's the most appropriate for my needs.Can you help me if i am wrong?Here is my code:
view <?php echo $form->create('User', array('action' => 'change_status')); echo $form->input('User.status', array ('type' => 'checkbox','label'=> 'Status','options'=>array(1=>'Active', 0=>'Inactive'))); echo $form->input('id', array('type'=>'hidden')); echo $form->end('Save'); ?> controller function change_status($id=null){ $this->User->id = $id; if (empty($this->data)) { $this->data = $this->User->read(); } else { if ($this->User->save($this->data)) { $this->Session->setflash('User status has been updated!'); $this->redirect('/users'); } } } Ty in advance! On May 3, 7:24 pm, brian <bally.z...@gmail.com> wrote: > Cake has no official support forENUM. (there may be ways to use them, > of course) > > The simplest way to deal with this would be to change your column to > (mysql version): > > active BOOLEAN DEFAULT FALSE (or TRUE, whichever you want) > or > active BIT(1) DEFAULT 0 (or 1) > or > active TINYINT(1) DEFAULT 0 (or 1) > > .. which, for mysql, amounts to the same thing. > > If you foresee having more than 2 types ofstatus, create a table, > statuses, give users a status_id andUserhasOneStatus. > > On Sun, May 3, 2009 at 11:30 AM, Paulos23 <paulitosthe...@gmail.com> wrote: > > > Hi Cake people, > > I have a problem in settinguserstatus.In particular i have a field > > in users table which is calledstatusand i have set it toenum > > ('active','inactive') default 'active'.now in users/views/ > > change_status i want to have a select tag to setstatusas active or > > inactive.Here is the code: > > > <?php > > echo $form->create('User', array('action' => 'change_status')); > > echo $form->input('User.status', array ('type' => 'select','label'=> > > 'Status','options'=>array(1=>'active',0=>'inactive'))); > > > echo $form->input('id', array('type'=>'hidden')); > > echo $form->end('Save'); > > ?> > > > Now in users_controller i want a change_status fanction to edit the > > changes.But when i select a choice nothing happen.Can you please help > > me ? > > > My code in controller: > > > function change_status($id=null){ > > $this->User->id = $id; > > if (empty($this->data)) { > > $this->data = $this->User->read(); > > } else { > > if ($this->User->save($this->data)) { > > $this->Session->setflash('Userstatushas 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 -~----------~----~----~----~------~----~------~--~---