Hello Luigi,

I would do it the following way:
In your controller parse your array and create a new one which contains teh 
desired values. Pass this array via $this->set on to the view.

Maybe there is a more elegant way to do it, but this is how I do it.

anja

-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[EMAIL PROTECTED] Im Auftrag von luigi7up
Gesendet: Mittwoch, 19. November 2008 11:42
An: CakePHP
Betreff: Help with populating SELECT drop down


Hello I need help with populating drop down select element.

I have following data in array $product that is available in my view

Array
(
    [Product] => Array
        (
            [id] => 1
            [product_category_id] => 1
            [user_id] => 26
            [title] => Nije Vuk Ovca
            [folder] => nije_vuk_ovca
            [price] => 85
            [special] => 0
            [published] => 1
            [created] =>
            [modified] => 2008-11-07 11:56:06
        )

    [ProductVariant] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [product_id] => 1
                    [sex] => male
                    [size] => S
                    [extras] =>
                    [price] =>
                )

            [1] => Array
                (
                    [id] => 2
                    [product_id] => 1
                    [sex] => male
                    [size] => M
                    [extras] =>
                    [price] =>
                )

            [2] => Array
                (
                    [id] => 3
                    [product_id] => 1
                    [sex] => male
                    [size] => L
                    [extras] =>
                    [price] =>
                )

)

****
As you can see Product has it's variants because PRODUCT model hasMany 
PRODUCT_VARIANTS.
In my product view I want drop down menu (SELECT) with all variants of product 
to be populated in following way:

<select name="xxx" action="yyy">
<option value="product_variant_id">sex | size - price</option> </select>

What I was able to do is
echo $form->select("variant",$product[ProductVariant]);

but this populates dropDown with every table attribut in its own <OPTION> field.

I would like something like this:

form->select("variant",$product[ProductVariant][size]);

but with few more attributes (size + sex + price).

Hope I was clear enough what I want to do...

Thank you so much

Luka



--~--~---------~--~----~------------~-------~--~----~
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