tree behaviour and validation rule problem

2010-02-02 Thread emmexx
I wrote a simple model that acts as a tree behaviour. The model has a myfield_id field that must follow these rules: - if parent_id is empty (root) myfield_id can't be blank - if parent_id is not empty myfield_id must be blank (children) So I wrote a isUnique validation rule for myfield_id. And

Re: tree behaviour and validation rule problem

2010-02-02 Thread John Andersen
As I can't see your full code from the moment you retrieve the Category and until you try to save it, I can't be sure that you have provided the Category.id at the time of saving the updated parent_id. I just imagine that CakePHP actually may try to add a new record, in which case the isUnique

Re: tree behaviour and validation rule problem

2010-02-02 Thread emmexx
On 2 Feb, 15:45, John Andersen j.andersen...@gmail.com wrote: As I can't see your full code from the moment you retrieve the Category and until you try to save it, I can't be sure that you have provided the Category.id at the time of saving the updated parent_id. I just imagine that CakePHP