I know you've already had a few replies, but can you outline in a simple non-code sentence exactly what you are trying to achieve (rather than why your code isn't working)?
Jeremy Burns Class Outfit jeremybu...@classoutfit.com (t) +44 (0) 208 123 3822 (m) +44 (0) 7973 481949 Skype: jeremy_burns http://www.classoutfit.com On 14 Feb 2011, at 06:28, adam_g2000 wrote: > The edit method in my controller is successfully being passed a > variable called $categoryID. I'm using the variable to query another > model, which happens successfully and the title field from the model > is displayed in the view via the variable defined here. > > App::import('Model','Category'); > $cat = new Category(); > $category = $cat->field('title', array('id' => $categoryID)); > $this->set('category', $category); > > My problem arises in the second if statement in the method. By the > time I need the variable to pass through redirect it seems to have > fallen out of scope and I cannot figure out why - the variable appears > to be empty. > > Here is the method. > > function edit($id = null, $categoryID = null) { > App::import('Model','Category'); > $cat = new Category(); > $category = $cat->field('title', array('id' => $categoryID)); > $this->set('category', $category); > if (!$id && empty($this->data)) { > $this->Session->setFlash(__('Invalid subcategory', > true)); > $this->redirect(array('action' => 'index')); > } > if (!empty($this->data)) { > if ($this->Subcategory->save($this->data)) { > $this->Session->setFlash(__('The subcategory > has been saved', > true)); > $this->redirect(array( > 'controller' => 'subcategories', > 'action' => 'index', > $categoryID > )); > } else { > $this->Session->setFlash(__('The subcategory > could not be saved. > Please, try again.', true)); > } > } > if (empty($this->data)) { > $this->data = $this->Subcategory->read(null, $id); > } > $categories = $this->Subcategory->Category->find('list'); > $resources = $this->Subcategory->Resource->find('list'); > $this->set(compact('categories', 'resources')); > } > > Please be gentle, I've spent a couple of months now reading the > cookbook and a textbook and a series of tutorials - though I am a > newbie! If anyone can offer any assistance and point out why this > might be I'd be very grateful. Thanks in advance. > > Adam. > > -- > 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 > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php -- 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php