Please have a look at this validation array in my cakephp app for model Unit:
public $validate=array(
'type'=>array(
'rule'=>'notEmpty',
'message'=>'You must choose what type of property this is.'
),
'unitnum'=>array(
'rule'=>array('custom', '/^[a-z0-9 -\'.\/&]*$/i'),
'message'=>'Must be the name or number of your unit.'
),
'unit_website'=>array(
'rule'=>'url',
'message'=>'You must enter a valid website address.'
),
'specials'=>array(
'rule'=>'url',
'message'=>'You must enter a valid website address.'
),
'rates'=>array(
'rule'=>'url',
'message'=>'You must enter a valid website address.'
),
'book'=>array(
'rule'=>'url',
'message'=>'You must enter a valid website address.'
),
'contact'=>array(
'rule'=>'url',
'message'=>'You must enter a valid website address.'
)
);
Every rule EXCEPT the one for ‘specials’ works. I thought I maybe misspelled it in my validation array, my form or my database field, but it’s spelled correctly.
So then I tried moving it around in the array. That didn’t work. I tried deleting it and rewriting it by hand. No go.
I thought, well maybe the file /tmp/cache/models/cake_model_defaults_units was to blame. I deleted that, and still it doesn’t work.
Then I verified that the uploaded copy of my Unit.php model definition was the most current, up to date version. Yep, it is.
Even weirder, I tried adding new fields like ‘foo’ and ‘bar’ into my database, then giving them validation rules (like ‘url’ or ‘numeric’). Every single time, no matter what I enter in the form fields, their validation does NOT fail, and cake updates my database.
What am I missing?
Problem was, after help from @Paulo Rodrigues, that I had TWO copies of my model on my server (ouch!). Deleted them both and installed a fresh copy of the correct model.