punktress Posted May 18, 2010 Share Posted May 18, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/202130-cakephp-data-not-saving/ Share on other sites More sharing options...
jcombs_31 Posted May 20, 2010 Share Posted May 20, 2010 I'm assuming you added delivery to the database? Did you clear the model cache in tmp? Quote Link to comment https://forums.phpfreaks.com/topic/202130-cakephp-data-not-saving/#findComment-1061056 Share on other sites More sharing options...
punktress Posted May 22, 2010 Author Share Posted May 22, 2010 You are AWESOME! Thanks so much! I cleared the cache and it worked like a charm. Thanks a million times over! Quote Link to comment https://forums.phpfreaks.com/topic/202130-cakephp-data-not-saving/#findComment-1061970 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.