Here’s a link to 15 essential CakePHP tips. They are extremely helpful. Tips #1 and #2 alone are worth the look. (hint: these tips explain why save() “mysteriously” stops working. It’s probably because of validation conflicts. E.g. when you are trying to update only a few model fields and but have other fields marked as “required”. This happened to me while I was creating a change password form. My form only had three fields: old password, new password, and retype new password; but my validation rules for the User model said that a username was required, thus validation failed without a warning.)
I’ve only been working with CakePHP for a little more than 3 weeks but I’ve learned a few good tips of my own. Please comment to correct my noob misconceptions!
- Temporarily turn off validation rules in a controller. save() isn’t working for you because of the problem cited above? then use the following code to temporarily bypass individual validation requirements.
unset($this->Model->validate['fieldname']);
- See the entire structure of variables passed to your view from your controllers: The following code prints a very nicely formatted view of the entire array:
In your controller:
$this->set('variable','value');
In your view:
pr($variable); - Join the crowd in IRC! man those folks are helpful! (Colloquy is a fantastic free IRC client for Mac, Windows users, let me know in the comments what’s good!)
- More will be forth coming as I think of them!