Product, ProductVariant, Cart
Product (hasMany ProductVariants )
ProductVariants (belongsTo Product & Cart)
Cart (hasMany ProductVariants)
In my Product View action I have following form to add products to
Cart table with session_id as identifier of whoes products are in
cart:
$form->create('Product',array
('action'=>'addToCart','id'=>'add','class'=>'form'));
echo $form->input('quantity');
echo $form->submit();
echo $form->end();
There is also a Drop down menu in this form to choose a product
variant id (SEX and SIZE) but for sake of simplicity I'm gonna leave
it out.
Now, first I had my "addToCart" action defined in cart_controloler but
then I moved it to Products::addToCart.
I want to validate my field quantity that it is a numeric value and if
it's not I want error next to that input field.
My Products::addToCart action looks like this:
if($this->Product->ProductVariant->Cart->save($this->data,true))
{
$this->Session->setFlash(__('Added to cart', true));
}
else
{
$this->Session->setFlash(__('Problem!', true));
}
$this->redirect(array('action'=>'view','id'=>$this->data['Product']
['product_id']));
No matter where I define my $validate variable (Cart or Product) my
validation doesn't throw an error ?!?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment