CakePHP Observe field for validation check(already exists)
- by deck john
i have already user observe field in cakephp 1.3 Now i want to do the same thing in cakephp 2.0
I have one form.there is a one field named email. When user insert email. onblur there is a popup one message that displays "email already exists" or "right"
for that i have write below code in my projects. the below code is my add file code
<?php $options = array('url' => array( 'controller' => 'users', 'action' => 'is_exist'), 'update' => 'email_exist');
echo $this->ajax->observeField('UserEmailId',array('url' => array( 'controller' => 'users', 'action' => 'is_exist'), 'update' => 'email_exists')); ?>
In my controller i have created one function like
public function is_exist($id = null)
{
$result = "yes";
$this->set('existdata',$result);
}
i have also created is_exists.ctp fiel in view/uers.
i dont know why its not working.
i did the same thing in Cakephp 1.3 and its working file but not in cakephp 2.0
can anyone tell me how i implement this ?
thanks in advance