Jump to content

CakePHP - Data not saving


punktress

Recommended Posts

Sorry guys, I'm a complete N00B with CakePHP.  I took on a simple project to edit an existing site without realizing it was done in Cake.  The site has an order form and the customer wanted a delivery method added to the order form.  The info needed to save to the DB and go out in the confirmation email.  Clearly I'm doing something wrong because the data is NOT saving to the database.  It IS however going out in the email, so it's only half wrong!

 

The original code that worked correctly for saving the data looked like this (products_controller.php):

$this->Order->save(array('Order' => array(

          'client_id' =>$this->Auth->user('id'),

          'po_number' => $this->data['Product']['PO number'],

          'comments' => $this->data['Product']['comments'])

        ));

 

I modified it to look like this:

$this->Order->save(array('Order' => array(

          'client_id' =>$this->Auth->user('id'),

          'po_number' => $this->data['Product']['PO number'],

          'comments' => $this->data['Product']['comments'],

          'delivery' => $this->data['Product']['delivery'])

        ));

 

 

 

The form code looks like this (checkout.ctp):

<div class="products form">

<?php echo $form->create('Product', array('action' => 'checkout'));?>

<fieldset>

<legend><?php __('Submit Order');?></legend>

<?php

echo $form->input('PO number');

echo $form->input('comments', array('type' => 'textarea'));

$options=array('Pick-Up'=>'Pick-Up','Delivery'=>'Delivery');

echo "Delivery Method ";

echo $form->select('delivery',$options, 'Pick-Up', false, false);

?>

 

<?php echo $form->end('Confirm Order');?>

</fieldset>

</div>

 

 

I added this portion:

$options=array('Pick-Up'=>'Pick-Up','Delivery'=>'Delivery');

echo "Delivery Method ";

echo $form->select('delivery',$options, 'Pick-Up', false, false);

 

 

It is also not pulling the data into the order view page.

 

What am I missing?

Link to comment
https://forums.phpfreaks.com/topic/202130-cakephp-data-not-saving/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.