title: How to validate a dropdown list with months on CakePHP
body: <p>I've been seraching for weeks how to do that but didn't find any good answer. I mean I thought it was supposed to be easy to do that, but not at all. Here's the thing, I have to ask the user to choose a month interval so I can show the right data to him. Since it's not related to any table I have on my database, I just did this:</p>
  
  <pre><code>&lt;?php
  echo $this-&gt;Form-&gt;create(false);
  echo $this-&gt;Form-&gt;month('m1', null, array('monthNames' =&gt; false));
  echo ' until ';
  echo $this-&gt;Form-&gt;month('m2', null, array('monthNames' =&gt; false));
  echo $this-&gt;Form-&gt;end('Choose');
  ?&gt;
  </code></pre>
  
  <p>And then created a simple rule at the model (there's only a rule for one field, for test purpose):</p>
  
  <pre><code>var $validate = array('m1' =&gt; array('rule' =&gt; 'notEmpty', 'required' =&gt; true, 'message' =&gt; 'Error!'));
  </code></pre>
  
  <p>Here's my controller:</p>
  
  <pre><code>function choose_date ($id = null) {
      if (!empty($this-&gt;data)) {
          $this-&gt;Frequency-&gt;set($this-&gt;data);
          if ($this-&gt;Frequency-&gt;validates()) {
              $fD = $this-&gt;data['m1']['month'].'/'.date('Y');
              $tD = $this-&gt;data['m2']['month'].'/'.date('Y');
              $this-&gt;Session-&gt;write('Frequency.fromDate', $fD);
              $this-&gt;Session-&gt;write('Frequency.toDate', $tD);
              $this-&gt;redirect(array('action' =&gt; 'view'));
          }
      } else { $this-&gt;Session-&gt;write('Worker.id', $id); }
  }
  </code></pre>
  
  <p>So what happens is that it just freezes at the "choose_date" view, doesn't matter if do or don't select anything on the list. How can I validate it?  It's probably a simple task but it's getting me crazy!</p>