I noticed when I was working through the examples, including the downloaded examples, there were errors. In case anyone is is having problem with the CakePHP code, let me suggest the fixes below:
On page 110 in the book, makes sure line 2 of the edit code looks like this:
echo $form->create('Address', array('action' => 'edit'));
Note the use of => instead of the books -> . This will fix one issue. The downloaded code had this correct.
The other problem is the way links are built for editing, viewing and deleting. If you follow the book and downloaded code you will always have a null $id. Instead use the following format for building links:
It's important to note that I removed the
instead opting for the straight $address['id']. The reason? Your links will be correct. The incorrect format makes the link parameters look like this
instead of the correct
. If you follow the book chapter four, the ID will always be null because of this. Make the suggested correction above and you can view, edit and delete no problem.
I hope this helps someone out. Took me 30 minutes to figure this out, since I am still learning CakePHP.