The key/value tables (EAV model) are a nice a approach to database modeling, when we need to store some arbitrary data about another model.
(part 1)
Now, how is this an introduction to jQuery + CakePHP?… well, let’s see in a minute.
In all the time I’ve been following cake on IRC (almost daily), it has become very clear that other than ACL and maybe Auth, ‘required’=>true in the model validation is the most confusing part of CakePHP for many people.
Here’s another trick with Set::merge()…
Let’s say we’ve defined some basic validation rules in our Profile model, something like:
With the recent changeset (https://trac.cakephp.org/changeset/7399) a new, ‘notEmpty’, validation rule is now available. As you can guess, it checks to make sure that a field contains something other than a white space.
In a few simple words: use the ‘comparison’ rule to validate a checkbox.
To give you an example, let’s say a user needs to agree to the terms of service when registering a new account. In your User model you setup a rule for the checkbox as…
A nice little trick to check if you have some errors in the view is to use the $session object.
Try this (in the view): pr($this->validationErrors) or pr($session->validationErrors), be sure to actually have some errors in the form…