title: How to insert multiple table for one form add in cakephp
body: <p>so i want to create one form add for 3 tables, but i dont understand the scipt, i am googling but, i dont know, can anyone help me?</p>
  
  <p>Table pln_nontaglish_suspect</p>
  
  <pre><code> | id | trx_id | no_regristrasi | tgl_regristrasi | nama | id_pel | rptag | switching_ref | admin_charge | iso | xml | inbox_id | telepon | info | jenis_transaksi | tagihan | partnet_cid | merchant | pln_ref |  bank_code |dt_trx | reprint | create_date|
  </code></pre>
  
  <p>Table Mutations </p>
  
  <pre><code>| id | amount | note | jenis | inbox_id | balance | create_date | create_by | update_date | update_by | user_id | version |
  </code></pre>
  
  <p>Table Transactions</p>
  
  <pre><code>| id | user_id | product_id | destination | sender | sender_type | create_date | price_sell | price_buy | inbox_id | status | remark | saldo_awal | sn | receiver | resend
  </code></pre>
  
  <p>in the form add.ctp</p>
  
  <pre><code>&lt;div id="page-container" class="row"&gt;
  
  &lt;div id="page-content" class="col-sm-9"&gt;
  
      &lt;!--&lt;h2&gt;&lt;?php echo __('Add Pln Nontaglist Suspect'); ?&gt;&lt;/h2&gt;--&gt;
  
      &lt;div class="plnNontaglistSuspects form"&gt;
  
          &lt;?php echo $this-&gt;Form-&gt;create('PlnNontaglistSuspect', array('role' =&gt; 'form')); ?&gt;
  
          &lt;table&gt;
              &lt;div style="display:none"&gt;
              &lt;?php
  
                  $now = new DateTime();
                  $today = $now-&gt;format("Y-m-d H:i:s");
  
                  $user = $this-&gt;Session-&gt;read('Auth.User.username');
  
                  $id = 'user_id';
  
                  $user_id = $_POST['Transaction.user_id'];
                  $inbox_id = $_POST['PlnNontaglistSuspect.inbox_id'];
  
  
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.trx_no');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.idpel');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.rptag');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.admin_charge');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.xml');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.telpon');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.info');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.merchant');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.pln_ref');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.bank_code');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.dt_trx');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.reprint');
                  echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.create_date', array('value' =&gt; $today));
  
                  //input for table mutations
                  echo $this-&gt;Form-&gt;input('Mutation.note');
                  echo $this-&gt;Form-&gt;input('Mutation.jenis');
                  echo $this-&gt;Form-&gt;input('Mutation.inbox_id', array('value' =&gt; $inbox_id));
                  echo $this-&gt;Form-&gt;input('Mutation.balance');
                  echo $this-&gt;Form-&gt;input('Mutation.create_date', array('value'=&gt;$today));
                  echo $this-&gt;Form-&gt;input('Mutation.create_by', array('value' =&gt; $user));
                  echo $this-&gt;Form-&gt;input('Mutation.update_date');
                  echo $this-&gt;Form-&gt;input('Mutation.update_by');
                  echo $this-&gt;Form-&gt;input('Mutation.user_id', array('value' =&gt; $user_id));
                  echo $this-&gt;Form-&gt;input('Mutation.version');
  
                  //input for table transactions
                  //echo $this-&gt;Form-&gt;input('Transaction.user_id', array('value' =&gt; $id));
                  echo $this-&gt;Form-&gt;input('Transaction.destination');
                  echo $this-&gt;Form-&gt;input('Transaction.sender');
                  echo $this-&gt;Form-&gt;input('Transaction.sender_type');
                  echo $this-&gt;Form-&gt;input('Transaction.create_date', array('value' =&gt; $today ));
                  echo $this-&gt;Form-&gt;input('Transaction.price_buy');
                  echo $this-&gt;Form-&gt;input('Transaction.status');
                  echo $this-&gt;Form-&gt;input('Transaction.saldo_awal');
                  echo $this-&gt;Form-&gt;input('Transaction.sn');
                  echo $this-&gt;Form-&gt;input('Transaction.receiver');
                  echo $this-&gt;Form-&gt;input('Transaction.resend');
  
  
              ?&gt;
  
              &lt;/div&gt;
              &lt;legend&gt;Tambah Nontaglish&lt;/legend&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;No Regristrasi&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.no_registrasi', array('label' =&gt; false,'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Tgl Regristrasi&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.tgl_registrasi', array('label' =&gt; false,  'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Inbox Id&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.inbox_id', array('label' =&gt; false, 'type' =&gt; 'text', 'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Produk Id&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('Transaction.product_id', array('label' =&gt; false, 'empty' =&gt; '----Select Produk Id----', 'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;User Id&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('Transaction.user_id', array('label' =&gt; false, 'empty' =&gt; '----Select User Id----','class' =&gt; 'form-control'));?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Nama Pelanggan&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.nama', array('label' =&gt; false, 'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Price Sell&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;Input('Transaction.price_sell', array('label' =&gt; false, 'class' =&gt; 'form-control'));?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Iso&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.iso', array('label' =&gt; false,'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Switching Ref&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.switching_ref', array('label' =&gt; false, 'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Tagihan&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.tagihan', array('label' =&gt; false,'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Partner Cid&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.partner_cid', array('label' =&gt; false, 'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Amount&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('Mutation.amount', array('label' =&gt; false, 'class' =&gt; 'form-control'));?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Remark&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('Transaction.remark', array('label' =&gt; false, 'class' =&gt; 'form-control'));?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Jenis Transaksi&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&amp;nbsp; : &amp;nbsp;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $this-&gt;Form-&gt;input('PlnNontaglistSuspect.jenis_transaksi', array('label' =&gt; false,'class' =&gt; 'form-control')); ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;?php echo $this-&gt;Form-&gt;submit('Submit', array('class' =&gt; 'btn btn-large btn-primary')); ?&gt;
  
  
          &lt;?php echo $this-&gt;Form-&gt;end(); ?&gt;
  
      &lt;/div&gt;&lt;!-- /.form --&gt;
  
  &lt;/div&gt;&lt;!-- /#page-content .col-sm-9 --&gt;
  </code></pre>
  
  <p></p>
  
  <p>And In the Controller</p>
  
  <pre><code>public function add() {
      $this-&gt;loadModel('Product');
      $this-&gt;loadModel('User');
      if ($this-&gt;request-&gt;is('post')) {
          $this-&gt;PlnNontaglistSuspect-&gt;create();
          if ($this-&gt;PlnNontaglistSuspect-&gt;save($this-&gt;request-&gt;data)) {
              $this-&gt;Session-&gt;setFlash(__('The pln nontaglist suspect has been saved'), 'flash/success');
              $this-&gt;redirect(array('action' =&gt; 'index'));
          } else {
              $this-&gt;Session-&gt;setFlash(__('The pln nontaglist suspect could not be saved. Please, try again.'), 'flash/error');
          }
      }
  
      //$inboxes = $this-&gt;PlnNontaglistSuspect-&gt;Inbox-&gt;find('list');
      $products = $this-&gt;Product-&gt;find('list');
      $users = $this-&gt;User-&gt;find('list',array(
              'fields'=&gt;array('User.id','User.username'),
              'order'=&gt;array('User.username')                
              )
      );
      $this-&gt;set(compact('products','users'));
  }
  </code></pre>