title: CakePHP: Submitting a multiple checkbox input into the database
body: <p>I have a checkbox in a Cakephp form that can have multiple values.  In the view:</p>
  
  <pre><code>&lt;?php // Multiple checkbox form
          echo $this-&gt;Form-&gt;input('report_types', array(
          'type'=&gt;'select',
          'label'=&gt;'Report Type(s)',
          'multiple'=&gt;'checkbox',
          'options'=&gt;array(
              'option 1'=&gt;'option 1',
              'option 2'=&gt;'option 2',
              'option 3'=&gt;'option 3',
          ),
  )); ?&gt;
  </code></pre>
  
  <p>When I load this into the database it returns a "Column not found: 1054 Unknown column 'Array' in 'field list'" error because it is trying to add an array where it should be a string.</p>
  
  <p>I've tried converting <em>any</em> of the <code>$this-&gt;request-&gt;data</code> that is in array form into a string, but that interferes with the date selects that I have earlier in the form (they are stored as arrays as well).</p>
  
  <p>I've also tried converting just the value of the multiple check-box field into a string in the <code>beforeValidate()</code> method in the model, but it requires too much repetition and gets messy when I need to 'unpack' the data:</p>
  
  <pre><code>&lt;?php class Request extends AppModel {
      ...
      function beforeValidate() {
          if(!empty($this-&gt;request-&gt;data['Request']['attachment_types'])) {
              $this-&gt;data['Request']['attachment_types'] = implode(',', $this-&gt;data['Request']['attachment_types']);
          }
          if(!empty($this-&gt;request-&gt;data['Request']['report_types'])) {
              $this-&gt;data['Request']['report_types'] = implode(',', $this-&gt;data['Request']['attachment_types']);
          }
          // Am I going to have to keep adding if-statements here? 
          }?&gt;
  </code></pre>
  
  <p>Besides, the <code>!empty()</code>method doesn't work because the field will never be empty (due to the hidden field automatically created when CakePHP makes a checkbox input).</p>
  
  <p>Does anyone have any ideas as to how I can submit a multiple check-box input into a database?  It seems like a pretty modest request...does CakePHP have any "automagic" skills in this respect?</p>