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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.