Re: user status enum
Hello, generally: I was looking for enum too for use types. You can use Has One relationships to extend users by types as well. (User HasOne Admin, User HasOne SuperUser, User HasOne Customer, User HasOne Client) Besides that, if you can/want to work with a boolean switch (is_admin TINYINT 1 UNSIGNED DEFAULT 0 (or 1) for instance) you should just use cake bake and see what controller and view code it generates because: that feature works out of the box (box = cake bake) each time I used that. King regards Jonas On May 4, 2:00 am, paulos nikolo wrote: > Yes you are right.Sorry for not being more accurate.The problem i am facing > is that when i select a choice check/uncheck the checkbox the controller > function dont do anything.In other words the new data in user status cant > replace the older.And i cant find if it is problem in form or in > controller.In my opinion i think it might be problem in the action > change_status coz the new data cant be saved. > > 2009/5/4 brian > > > > > It's usually best to state exactly what problems one is encountering. > > That being said, for a single checkbox, I usually use this format: > > > hidden('User.id'); ?> > > Active > > checkbox(’User.status’); ?> > > > > > The way you were doing it is more like what one would use for a select > > list. In your case, you only need a single checkbox with the value 1. > > If it's not present, the default 0 will be set (depending upon how you > > defined the column). > > > If the value is set in $this->data (say, in an edit form) Cake will > > take care of settingthe checkbox to the "checked" state. > > > On Sun, May 3, 2009 at 5:02 PM, paulos nikolo > > wrote: > > > I still have problem.And i can't figure out what cause it!I used a > > checkbox > > > and still nothing. > > > > view/change_status > > > > > > echo $form->create('User', array('action' => 'change_status')); > > > echo $form->input('User.status', array ('type' => > > 'checkbox','label'=> > > > 'Active','options'=>array(1=>'Active',0=>'Inactive'))); > > > echo $form->input('id', array('type'=>'hidden')); > > > echo $form->end('Save'); > > > ?> > > > > 2009/5/3 brian > > > >> That looks ok, I think. Did you try that? > > > >> One thing I noticed is that your form won't have $id in the action, so > > >> $this->User->id = $id; won't always work the way you expect. I usually > > >> do something along these lines: > > > >> function change_status($id=null) > > >> { > > >> if (empty($this->data)) > > >> { > > >> $this->data = $this->User->read(null, $id); > > >> } > > >> else > > >> { > > >> /* $id is in $data['User'] > > >> */ > > >> if ($this->User->save($this->data)) > > >> { > > >> $this->Session->setflash('User status has been > > >> updated!'); > > >> $this->redirect('/users'); > > >> } > > > >> On Sun, May 3, 2009 at 1:01 PM, Paulos23 > > wrote: > > > >> > 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 > > >> > > >> > 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 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 > > >> >> wrote
Re: user status enum
Yes you are right.Sorry for not being more accurate.The problem i am facing is that when i select a choice check/uncheck the checkbox the controller function dont do anything.In other words the new data in user status cant replace the older.And i cant find if it is problem in form or in controller.In my opinion i think it might be problem in the action change_status coz the new data cant be saved. 2009/5/4 brian > > It's usually best to state exactly what problems one is encountering. > That being said, for a single checkbox, I usually use this format: > > hidden('User.id'); ?> > Active > checkbox(’User.status’); ?> > > > The way you were doing it is more like what one would use for a select > list. In your case, you only need a single checkbox with the value 1. > If it's not present, the default 0 will be set (depending upon how you > defined the column). > > If the value is set in $this->data (say, in an edit form) Cake will > take care of settingthe checkbox to the "checked" state. > > > On Sun, May 3, 2009 at 5:02 PM, paulos nikolo > wrote: > > I still have problem.And i can't figure out what cause it!I used a > checkbox > > and still nothing. > > > > view/change_status > > > > > echo $form->create('User', array('action' => 'change_status')); > > echo $form->input('User.status', array ('type' => > 'checkbox','label'=> > > 'Active','options'=>array(1=>'Active',0=>'Inactive'))); > > echo $form->input('id', array('type'=>'hidden')); > > echo $form->end('Save'); > > ?> > > > > 2009/5/3 brian > >> > >> That looks ok, I think. Did you try that? > >> > >> One thing I noticed is that your form won't have $id in the action, so > >> $this->User->id = $id; won't always work the way you expect. I usually > >> do something along these lines: > >> > >> function change_status($id=null) > >> { > >>if (empty($this->data)) > >>{ > >>$this->data = $this->User->read(null, $id); > >>} > >>else > >>{ > >>/* $id is in $data['User'] > >> */ > >>if ($this->User->save($this->data)) > >>{ > >>$this->Session->setflash('User status has been > >> updated!'); > >>$this->redirect('/users'); > >>} > >> > >> On Sun, May 3, 2009 at 1:01 PM, Paulos23 > wrote: > >> > > >> > 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 > >> > >> >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 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 > >> >> 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: > >> >> > >> >> > >> >> >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', ar
Re: user status enum
It's usually best to state exactly what problems one is encountering. That being said, for a single checkbox, I usually use this format: hidden('User.id'); ?> Active checkbox(’User.status’); ?> The way you were doing it is more like what one would use for a select list. In your case, you only need a single checkbox with the value 1. If it's not present, the default 0 will be set (depending upon how you defined the column). If the value is set in $this->data (say, in an edit form) Cake will take care of settingthe checkbox to the "checked" state. On Sun, May 3, 2009 at 5:02 PM, paulos nikolo wrote: > I still have problem.And i can't figure out what cause it!I used a checkbox > and still nothing. > > view/change_status > > echo $form->create('User', array('action' => 'change_status')); > echo $form->input('User.status', array ('type' => 'checkbox','label'=> > 'Active','options'=>array(1=>'Active',0=>'Inactive'))); > echo $form->input('id', array('type'=>'hidden')); > echo $form->end('Save'); > ?> > > 2009/5/3 brian >> >> That looks ok, I think. Did you try that? >> >> One thing I noticed is that your form won't have $id in the action, so >> $this->User->id = $id; won't always work the way you expect. I usually >> do something along these lines: >> >> function change_status($id=null) >> { >> if (empty($this->data)) >> { >> $this->data = $this->User->read(null, $id); >> } >> else >> { >> /* $id is in $data['User'] >> */ >> if ($this->User->save($this->data)) >> { >> $this->Session->setflash('User status has been >> updated!'); >> $this->redirect('/users'); >> } >> >> On Sun, May 3, 2009 at 1:01 PM, Paulos23 wrote: >> > >> > 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 >> > > > 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 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 >> >> 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: >> >> >> >> > > >> > 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 >> >> > up
Re: user status enum
I still have problem.And i can't figure out what cause it!I used a checkbox and still nothing. view/change_status create('User', array('action' => 'change_status')); echo $form->input('User.status', array ('type' => 'checkbox','label'=> 'Active','options'=>array(1=>'Active',0=>'Inactive'))); echo $form->input('id', array('type'=>'hidden')); echo $form->end('Save'); ?> 2009/5/3 brian > > That looks ok, I think. Did you try that? > > One thing I noticed is that your form won't have $id in the action, so > $this->User->id = $id; won't always work the way you expect. I usually > do something along these lines: > > function change_status($id=null) > { > if (empty($this->data)) >{ >$this->data = $this->User->read(null, $id); >} >else >{ >/* $id is in $data['User'] > */ > if ($this->User->save($this->data)) >{ >$this->Session->setflash('User status has been > updated!'); >$this->redirect('/users'); >} > > On Sun, May 3, 2009 at 1:01 PM, Paulos23 wrote: > > > > 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 > > >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 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 > 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: > >> > >> > >> >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 -~--~~~~--~~--~--~---
Re: user status enum
That looks ok, I think. Did you try that? One thing I noticed is that your form won't have $id in the action, so $this->User->id = $id; won't always work the way you expect. I usually do something along these lines: function change_status($id=null) { if (empty($this->data)) { $this->data = $this->User->read(null, $id); } else { /* $id is in $data['User'] */ if ($this->User->save($this->data)) { $this->Session->setflash('User status has been updated!'); $this->redirect('/users'); } On Sun, May 3, 2009 at 1:01 PM, Paulos23 wrote: > > 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 > 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 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 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: >> >> > > > 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 -~--~~~~--~~--~--~---
Re: user status enum
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 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 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 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: > > > > 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 -~--~~~~--~~--~--~---
Re: user status enum
Cake has no official support for ENUM. (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 of status, create a table, statuses, give users a status_id and User hasOne Status. On Sun, May 3, 2009 at 11:30 AM, Paulos23 wrote: > > Hi Cake people, > I have a problem in setting user status.In particular i have a field > in users table which is called status and i have set it to enum > ('active','inactive') default 'active'.now in users/views/ > change_status i want to have a select tag to set status as active or > inactive.Here is the code: > > 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('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 -~--~~~~--~~--~--~---
user status enum
Hi Cake people, I have a problem in setting user status.In particular i have a field in users table which is called status and i have set it to enum ('active','inactive') default 'active'.now in users/views/ change_status i want to have a select tag to set status as active or inactive.Here is the code: 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('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 -~--~~~~--~~--~--~---