title: Save checkboxes to separate table using cakephp
body: <p>I have spaces that hold events and items that would incur charges.</p>
  
  <p>On the back-end, I want to add a space and the possible charges so I have a form with multiple select checkboxes for those charges.</p>
  
  <p>I want it to write the event space ID to the facility_event_spaces_id column and write the charges to facility_event_charges_id column in my 'event_charges' table.</p>
  
  <p>It's not saving anything to my table, event_charges.
  I may have something incorrect in the model or controller or both. Any cakephp gurus have suggestions? </p>
  
  <p>We're running cakephp 1.3. thanks!</p>
  
  <hr>
  
  <pre><code>&lt;tr&gt;
      &lt;td class="add"&gt;Charges:&lt;/td&gt;
      &lt;td&gt;
      &lt;?php echo $this-&gt;Form-&gt;input('charge', array('type'=&gt;'select', 'multiple' =&gt; 'checkbox', 'options'=&gt;$charges)); ?&gt;
      &lt;/td&gt;         
      &lt;/tr&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Q68Or.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q68Or.jpg" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>source view of add form</p>
  
  <pre><code>&lt;div class="checkbox"&gt;&lt;input type="checkbox" name="data[FacilityEventSpace][charge][]" value="1" id="FacilityEventSpaceCharge1" /&gt;&lt;label for="FacilityEventSpaceCharge1"&gt;Officials&lt;/label&gt;&lt;/div&gt;
  &lt;div class="checkbox"&gt;&lt;input type="checkbox" name="data[FacilityEventSpace][charge][]" value="2" id="FacilityEventSpaceCharge2" /&gt;&lt;label for="FacilityEventSpaceCharge2"&gt;Ushers&lt;/label&gt;&lt;/div&gt;
  &lt;div class="checkbox"&gt;&lt;input type="checkbox" name="data[FacilityEventSpace][charge][]" value="3" id="FacilityEventSpaceCharge3" /&gt;&lt;label for="FacilityEventSpaceCharge3"&gt;Additional Staffing&lt;/label&gt;&lt;/div&gt;
  &lt;div class="checkbox"&gt;&lt;input type="checkbox" name="data[FacilityEventSpace][charge][]" value="4" id="FacilityEventSpaceCharge4" /&gt;&lt;label for="FacilityEventSpaceCharge4"&gt;Special Lighting&lt;/label&gt;&lt;/div&gt;
  &lt;div class="checkbox"&gt;&lt;input type="checkbox" name="data[FacilityEventSpace][charge][]" value="5" id="FacilityEventSpaceCharge5" /&gt;&lt;label for="FacilityEventSpaceCharge5"&gt;Audio Visual Equipment&lt;/label&gt;&lt;/div&gt;
  &lt;div class="checkbox"&gt;&lt;input type="checkbox" name="data[FacilityEventSpace][charge][]" value="6" id="FacilityEventSpaceCharge6" /&gt;&lt;label for="FacilityEventSpaceCharge6"&gt;Audio Visual Technician&lt;/label&gt;&lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <p>my joinTable I created
  CREATE TABLE <code>event_charges</code> (
  <code>id</code> int (11) NOT NULL,
    <code>facility_event_spaces_id</code> int(11) NOT NULL,
    <code>facility_event_charges_id</code> int(11) NOT NULL,
    PRIMARY KEY  (<code>id</code>)
  );</p>
  
  <hr>
  
  <p>my Models</p>
  
  <pre><code>&lt;?php
  class FacilityEventSpace extends AppModel {
  var $name = 'FacilityEventSpace';
  var $hasAndBelongstoMany = array('FacilityEventCharge' =&gt;
                          array('className'    =&gt; 'FacilityEventCharge',
                                'joinTable' =&gt; 'event_charges',
                                'foreignKey'   =&gt; 'facility_event_spaces_id',
                                'associationForeignKey' =&gt; 'facility_event_charges_id',
                                'with' =&gt;'EventCharge'
                          ),
                    );
  } // end Model
  ?&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;?php
  class FacilityEventCharge extends AppModel {
  
  var $name = 'FacilityEventCharge';
  
  } // end Model
  ?&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;?php
  class EventCharge extends AppModel
  {
   var $name = 'EventCharge';                     
  } // end Model
  ?&gt;
  </code></pre>
  
  <hr>
  
  <p>My controller - facility_event_spaces_controller.php</p>
  
  <p>function add</p>
  
  <pre><code>$this-&gt;set('charges', $this-&gt;FacilityEventCharge-&gt;find('list', array('fields' =&gt; array('id', 'type'))  ));
  if (!empty($this-&gt;data)) {
      if($this-&gt;FacilityEventSpace-&gt;save($this-&gt;data))
                  {
  
                  $this-&gt;flash('The event space has been saved.','/FacilityEventSpaces/');
                          return;
                  } 
  }
  </code></pre>
  
  <hr>
  
  <p>also, here's the facility_event_charges table</p>
  
  <p><a href="https://i.stack.imgur.com/d4jhX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d4jhX.jpg" alt="enter image description here"></a></p>