title: cakePHP form custom validation
body: <p>Hi all I'm creating an invoice system and trying to make sure that the person sending the request, is sending it to a person who exists. The code that I currently have isn't working and was wondering if someone could give me a hand.</p>
  
  <p>model</p>
  
  <pre><code>   'exists'=&gt;array(
                     'rule'=&gt;'partytwo',
             'message'=&gt;'That username doesnt exist.'
          )); 
  
  
  
   function userExists($field=array(), $compare_field=null )
      {
          if($field['exists']= $compare_field)
          return TRUE;
          else return FALSE;
      }
  </code></pre>
  
  <p>and the validation in relationship the controller</p>
  
  <pre><code>if($this-&gt;request-&gt;is('post')){
      if($this-&gt;Relationship-&gt;validates(array('fieldlist'=&gt;array('partywo','Relationship.userExists')))){
      $this-&gt;Relationship-&gt;create(); 
      if ($this-&gt;Relationship-&gt;save($this-&gt;request-&gt;data)) 
      {
          $id=$this-&gt;Relationship-&gt;id;
          $this-&gt;Session-&gt;setFlash('The relationship has been saved');  
  
      }}
      else { $this-&gt;Session-&gt;setFlash('The relationship could not be saved. Please, try again.'); } 
      } 
  </code></pre>
  
  <hr>
  
  <p>here is my current model</p>
  
  <pre><code>  &lt;?php
      class Relationship extends AppModel{ 
      var $name='Relationship'; 
      public $useTable = 'relationships_users';
      public $primaryKey = 'id';
  
      var $validate = array(
          'date' =&gt; array(
          'rule' =&gt; array('datevalidation', 'systemDate' ),
          'message' =&gt; 'Current Date and System Date is mismatched'),
          'partytwo'=&gt;array(
                  'partytwoExists'=&gt;array(
                  'rule'=&gt; 'userExists',
                  'message'=&gt;'That username doesnt exist.'
               ))); 
  
   function datevalidation( $field=array(), $compare_field=null ) 
      {
          if ($field['date'] &gt; $compare_field)
  
          return TRUE;
          else return FALSE;
      }
  
   function userExists($check)
      {
  
          $userExists= $this-&gt;find('count', array('conditions'=&gt;$check));
          if($userExists == 1)
          {return TRUE;
          }
          else
          return FALSE;
      }
      }
  </code></pre>
  
  <p>its currently going straight to errors</p>