title: CakePHP validation rule automatically adding a required attribute to the field
body: <p>I am using a custom validation rule in CakePHP to be sure a value is entered into a field when a corresponding checkbox is marked:</p>
  
  <h2><img src="https://i.stack.imgur.com/fm6N9.jpg" alt="When the &quot;Purchasing TV&quot; checkbox is marked, there needs to be a value in the &quot;Enter TV Price&quot; field."></h2>
  
  <p>Here's the validation rule within my model's validation array...</p>
  
  <pre><code>'tv_price'=&gt;array(        
      'check'=&gt;array(
          'rule'=&gt;array('check_for_tv_price'),
          'message'=&gt;'Please enter the television pricing information.',
      ),
  )
  </code></pre>
  
  <p>...and here's my really simple custom validation function:</p>
  
  <pre><code>public function check_for_tv_price($check) {
      if($this-&gt;data['Client']['tv']==1&amp;&amp;$this-&gt;data['Client']['tv_price']=="") {
          return false;
      }
      if($this-&gt;data['Client']['tv']==1&amp;&amp;$this-&gt;data['Client']['tv_price']!="") {
          return true;
      }
      if($this-&gt;data['Client']['tv']==0) {
          return true;
      }
  
  }
  </code></pre>
  
  <p>I've tried adding <code>'required'=&gt;false</code> and <code>'allowEmpty'=&gt;true</code> at different points in the validation array for my <code>tv_price</code> field, but they always override my custom rule!  As a result, a user can not submit the form because the browser prevents it (due to the required attribute).  </p>
  
  <p>For reference, the browser spits out the following HTML:</p>
  
  <pre><code>&lt;input id="ClientTvPrice" type="text" required="required" maxlength="255" minyear="2013" maxyear="2018" name="data[Client][tv_price]"&gt;&lt;/input&gt;
  </code></pre>
  
  <p>(Note the minyear and maxyear attributes are from the form defaults.)</p>
  
  <p>Has anyone found a way to prevent the automatic insertion of the <code>required</code> attribute when using custom validation rules?</p>
  
  <p>Any guidance would be much appreciated.</p>
  
  <p>Thanks!</p>
  
  <p>Chris</p>