Thanks a million! On Mon, May 18, 2009 at 7:42 PM, brian <[email protected]> wrote:
> > On Mon, May 18, 2009 at 10:22 PM, Jorge Garifuna <[email protected]> > wrote: > > > > I'm creating an application with the following two tables: > > > > posts: > > - id > > - title > > - body > > > > comments: > > - id > > - post_id > > - comment > > > > I was able to bake this app and all the links are working. Now I would > > like to customize the app so that, when a comment is added from the > > post: > > > > - the post id (list) is not showing in the comment view > > Just delete it from your view. Bake creates very generic views and, > unless you change the templates, you'll generally need to clean them > up somewhat. > > > - the post id gets saved when the comment is saved > > $form->hidden('Comment.post_id') > > Depending on how you're doing things, you may need to do: > > $form->hidden('Comment.post_id', array('value' => $post_id)) > > ... that's if you've set the $post_id var. > > > - the comment gets redirected to the post the comment originated from > > after saving > > $this->redirect( > array( > 'controller' => 'Post', > 'action' => 'view', > $post_id > ) > ); > > Or, if you don't want the 'view' part in the URL, you might want > something like this: > > $this->redirect( > array( > 'controller' => 'Post', > 'action' => 'view', > 'id' => $post_id > ) > ); > > In which case your route would be: > > Router::connect( > '/posts/:id', > array('controller' => 'posts', 'action' => 'view'), > array('id' => '[0-9]+', 'pass' => array('id')) > ); > > > > -- Jorge Garifuna Professional Web Developer "Your Web Solution Partner" Garinet Media Network, LLC. 811 Wilshire Blvd. Suite 1705 Los Angeles, CA 90017 http://www.GariDigital.com Business Operating Hours: Monday - Friday: 9AM - 6 PM PST --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
