OK, point taken.

Never used afterSave before so not sure how they are supposed to work
with the function in the controller.

Currently I have the standard save function in the controller that
adds the row made up on item, qty and price.
Then in the model..

                function afterSave()
                                {
                                $this->data['Orderitem']['price'] = $price;
                                $this->data['Orderitem']['qty'] = $qty;

                                $total_price = $price*$qty;

                                
$this->params['data']['Orderitem']['total_price'] = $total_price;
                                
$this->Order->Orderitem->save($this->params['data']);

                                return true;
                                }

What I get is the [item] inserted but no price or qty and the
total_price tuple set to 0

Also the errors..

Notice: Undefined variable: price in /app/models/orderitem.php on line
18

Notice: Undefined variable: qty in app/models/orderitem.php on line 19

Notice: Undefined variable: qty in app/models/orderitem.php on line 21

Notice: Undefined variable: price in app/models/orderitem.php on line
21


Hope that's enough info. As always any help greatly appreciated!!
Thanks


On Mar 7, 1:44 pm, "Mariano Iglesias" <[EMAIL PROTECTED]>
wrote:
> Mike,
>
> Can I respectfully ask you that you provide more information as to why you
> "can't get it working"? It makes us waste emails to keep explaining that
> there's no easy way to tell what is wrong when you don't even tell us what's
> not working.
>
> So instead of just saying something doesn't work, show us what you wanted to
> do, how you were trying to do it (source code) and why you think it is not
> working (error message, queries sent to the database that you think are
> wrong, etc. etc.)
>
> -MI
>
> ---------------------------------------------------------------------------
>
> Remember, smart coders answer ten questions for every question they ask.
> So be smart, be cool, and share your knowledge.
>
> BAKE ON!
>
> blog:http://www.MarianoIglesias.com.ar
>
> -----Mensaje original-----
> De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
> de mike
> Enviado el: MiƩrcoles, 07 de Marzo de 2007 08:11 a.m.
> Para: Cake PHP
> Asunto: afterSave callbacks
>
> The problem is as follows: I want to add item, price and quantity into
> a table but I also want the total price (i.e. price*qty) to be
> inserted into the same row. I have played with afterSave callbacks in
> the model but I can get it working. Can anyone give me some advice and
> am I going about it the right way.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to