Ok guys, it seems i have the data (extra field 'stock' in the
association table) in $this->data when i edit a Product, something
like this, so the association table is auto-modelized:

[Size] => Array
        (
            [0] => Array
                (
                    [id] => 2
                    [name] => S
                    [position] => 2
                    [created] =>
                    [modified] =>
                    [ProductsSize] => Array
                        (
                            [id] => 248
                            [product_id] => 4
                            [size_id] => 2
                            [stock] => 0
                        )

                )

            [1] => Array
                (
                    [id] => 5
                    [name] => XL
                    [position] => 5
                    [created] =>
                    [modified] =>
                    [ProductsSize] => Array
                        (
                            [id] => 249
                            [product_id] => 4
                            [size_id] => 5
                            [stock] => 0
                        )

                )

        )

But i dont know how to update that stock value, i think the idea is,
like i explained before to get and input field for each row, so i can
specify the stock number for that particular association, in other
words, be able to fill that extra information.

On Sep 18, 12:59 am, VitillO <[EMAIL PROTECTED]> wrote:
> Hi guys, thanks for your replies.
>
> Right now, im my 'add' view of products, im getting a multiple select
> for the sizes, where i can select which sizes are available for that
> particular product, thats fine. The problem is that i need a stock
> number for each of this available sizes, so a multiple select wont
> work for me.
>
> An example would be:
>
> [ (checkbox) ] Small ----------- Stock [ input (a number) ]
> [ (checkbox) ] Medium ----------- Stock [ input (a number) ]
> [ (checkbox) ] Large ----------- Stock [ input (a number) ]
>
> So when i hit submit on the form, i can see the selected sizes for
> that product along with the stock value for each one. Thats what i
> need to achieve, but i dont know how to make the associations, neither
> the necessary models for this to work.
>
> @Adam: how does 'with' parameter works? i cant find the documentation
> for it
>
> On Sep 17, 11:28 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > You can create a model for your habtm association so you can add extra
> > fields, etc, using the "with" key. Something like this...
>
> > class Product extends AppModel {
>
> > ...
>
> > var $hasAndBelongsToMany = array(
> >     'Size' => array('className' => 'Size',
> >         'with' => 'ProductsSize', // <-- this here, class name can be
> > changed
> >         'joinTable' => 'products_sizes',
> >         'foreignKey' => 'product_id',
> >         'associationForeignKey' => 'size_id',
> >     ),
> > );
>
> > }
>
> > class ProductsSize extends AppModel {
> >     // and here is your joined class!
>
> > }
>
> > Hope that helps,
> > Adam
>
> > On Sep 18, 7:07 am, "Luiz Poleto" <[EMAIL PROTECTED]> wrote:
>
> > > You can create the column stock in the association table.In the form where
> > > you do the association, you can add a new field for the stock.
>
> > > At least that was what i understood from your question...
>
> > > Regards,
> > > Luiz Poleto
>
> > > 2008/9/17 VitillO <[EMAIL PROTECTED]>
>
> > > > Hi, i have the following structure for a tshirt online store:
>
> > > > Product HABTM Size
> > > > Size HABTM Product
>
> > > > Association table:
> > > > products_sizes
>
> > > > The problem is, i need a stocks system.
>
> > > > For example, say i have 50 pieces of S (size) for a particular tshirt,
> > > > before using cake i had a column 'stock' in the association table, so
> > > > i could retrieve the particular stock of that size, for that product,
> > > > but now with cake i dont know how i should make the association.
>
> > > > Any help?
>
> > > > Thanks!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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