I think you have a typo function admin_toggleactive($id = null){ if (!$id) return;
$this->layout = 'ajax'; $this->autoRender = false; $this->Project->id = $id; // And not $this->id = $id $project = $this->Project->read(); > -----Messaggio originale----- > Da: cake-php@googlegroups.com > [mailto:[EMAIL PROTECTED] Per conto di [EMAIL PROTECTED] > Inviato: venerdì 16 marzo 2007 7.44 > A: Cake PHP > Oggetto: savefield woes > > > Quick question: > > I have this function to toggle an 'active' field un a project model, > > > function admin_toggleactive($id = null){ > > $this->layout = 'ajax'; > $this->autoRender = false; > > if ($id) { > $this->id = $id; > } > if (!$this->id) return; > > $project = $this->Project->read(); > if($project['Project']['active']=='1'){ > $this->Project->saveField('active','0'); > } > else{ > $this->Project->saveField('active','1'); > } > > $this->data = $this->Project->read(); > $this->render('../elements/project_set_unset_active'); > > } > > Now this wont work, the data returned to the element is the > same data (without the field toggled). BUT if I replace this line > > $this->data = $this->Project->read(); > > to > > $this->data = $this->Project->findById($id); > > the element will be rendered with the new data (the actual > value of the toggled field). > > Why does this happen ? Is this the only way to work around this? > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---