Things that took me longer than necessary to find
Here are some tips from newbie to newbie, with problems and their solutions as I came across them whilst testing the cakePHP framework. Let me know if they help you...or if there is a problem.
- Adding a title attribute to $html->link
I have no idea why this isn't found here but to add attributes such as title, class or ids to a link, you need to add a third parameter as an array:
echo $html->link($dolist['Dolist']['name']), array('controller'=>'Dolist','action'=>'view', $dolist['Dolist']['id']),array('title'=>$dolist['Dolist']['description']));
where the first is the text displayed the second array is the actual link, divided into controller (optional), action and parameters, and the third takes all yout html attributes like title.
- Deleting related items
Deleting related items(i.e. all posts when a thread is deleted) is a breeze with cakePHP. All you need to do is make that model dependent (not dependant, a typo that cost me 20 minutes). So in my posts model I would have
var $belongsTo = array('Thread' => array('className' => 'Thread','foreignKey' => 'thread_id','dependent'=> true));

Write a comment
Posts: 1
Reply #1 on : Wed July 14, 2010, 21:58:29