Thanks for pointing that out Ryan, I'm sorry I should have been more clear. I know why the error is occurring in the page (I can see currently there is the opportunity for it not to be set, and will revise that once I've finished sorting out the fact that it's not being sent by 'redirect'), it's the cause of the variable being MIA when redirect should be sending it that I need to fix first.
The bug you've pointed out is (right now), kinda helpful in that it lets me know that categoryID is missing when it should be populated by redirect. I still have no idea why I'm not getting any parameters from redirect in my edit method: $this->redirect(array( 'controller' => 'subcategories', 'action' => 'index', $categoryID )); On Feb 14, 11:58 am, Ryan Schmidt <google-2...@ryandesign.com> wrote: > On Feb 13, 2011, at 16:50, adam_g2000 wrote: > > > > > > > On Feb 14, 11:48 am, adam_g2000 wrote: > >> However I still have the problem with redirect. It doesn't seem to be > >> sending the variable, or my controller is not reading it. When I > >> reference the variable in the view, I get the error "Notice 8: > >> Undefined variable: categoryID [APP/views/subcategories/index.ctp, > >> line 44]" Here is my revised code: > > > In case the index controller is useful, here it is. > > > function index($categoryID = null) { > > if (!empty($categoryID)) { > > App::import('Model','Category'); > > $cat = new Category(); > > $category = $cat->field('title', array('id' => > > $categoryID)); > > $this->set('category', $category); > > $this->set('categoryID', $categoryID); > > $conditions = array( > > 'conditions' => array( > > 'Category.id' => > > $categoryID), > > 'order' => 'Subcategory.order > > ASC' > > ); > > $subcategories = $this->Subcategory->find('all', > > $conditions); > > } else { > > $this->set('category', 'All'); > > $conditions = array( > > 'order' => array( > > 'Category.title' => > > 'ASC', > > 'Subcategory.order' => > > 'ASC' > > ) > > ); > > $subcategories = $this->Subcategory->find('all', > > $conditions); > > } > > $this->Subcategory->recursive = 0; > > $this->set('subcategories', $subcategories); > > } > > Well, I see a path through this code that would result in categoryID not > being set in the view. Do you? When function index is called without a > parameter (i.e. when you access a URL without the id), then > $this->set('categoryID', $categoryID) is not called, hence categoryID is not > set in the view, hence PHP tells you that. > > If you're going to set up your controller's index method that way (where the > categoryID is optional), then you need to code your index template to allow > categoryID to be optional as well. -- 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