Hello,

I'm trying to make a correct validation for my model. To do that i
have to check the unicity of one of my field (the field named "texte")

Here is my code of my function:
function isUnique($data, $name)
        {
                $found = $this->find($this->name.".$name=\"".$data.'"');
                $same = isset($this->id) && $found[$this->name]['id'] == 
$this->id;
                return !$found || $found && $same;
        }

And my validate variable:
var $validate = array(
             'texte' => array(  'required' => array(
                                'rule' => VALID_NOT_EMPTY,
                                'message' => 'Veuillez entre un texte !'),
               'unique' => array('rule' => array('isUnique','texte'),
               'message' => 'Ce nom de menu existe déjà')
               ));

It's beautiful but it doesn't work ! It work when i add an item. But
when i update, it check also the unicity and i can't update an item...

If anybody can help me, thanks a lot

Gil

Sorry for my english...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to