Hi,

First, I'm not sure that works  :

 <?php foreach($form as $cartItemForm): ?>
         <tr>
           <td><?php echo $cartItemForm['quantity']->renderLabel() ?></
td>
           <td><?php echo $cartItemForm['quantity'] ?></td>
           <td></td>
         </tr>
       <?php endforeach; ?>

It doesn't match with what you wrote in your form, what do you have in
your action file?

You should have in your view something like that :
<?php foreach($form->getEmbeddedForms() as $cartItemForm): ?>
         <tr>
           <td colspan="2"><?php echo $cartItemForm ?></td>
      </tr>
<?php enforeach ?>

Second (this is a really special gift, I spend several weeks to find
this tricks on the net, so I'm waiting for sf1.3 
http://trac.symfony-project.org/ticket/5264)
If you want to design your embedded forms you should use this code in
the foreach :
        $nameFormat = $form->getWidgetSchema()->generateName($name) .
'[%s]';
        $cartItemForm->getWidgetSchema()->setNameFormat($nameFormat);
else the name used in fields will be the same, then the form can't
work.

Then you have now your array of sfForm, you can get the embedded forms
of the embedded form.
$cartItemForm->getEmbeddedForms()

On May 21, 8:33 pm, Tom Haskins-Vaughan <t...@templestreetmedia.com>
wrote:
> Hi,
>
> I have successfully embedded a form like so:
>
> class CartForm extends BaseCartForm
> {
>    public function configure()
>    {
>      unset(
>        $this['id'],
>        $this['is_default'],
>        $this['buyer_id']
>      );
>
>      foreach($this->getObject()->getCartItems() as $cartItem)
>      {
>        $this->embedForm(
>          'cartitem_'.$cartItem->cart_id.'_'.$cartItem->harvest_id,
>          new CartItemForm($cartItem)
>        );
>      }
>    }
>
> }
>
> And I have managed to display it like so:
>
> <form method="post" action="<?php echo url_for('@my_cart') ?>">
>      <tbody>
>        <?php foreach($form as $cartItemForm): ?>
>          <tr>
>            <td><?php echo $cartItemForm['quantity']->renderLabel() ?></td>
>            <td><?php echo $cartItemForm['quantity'] ?></td>
>            <td></td>
>          </tr>
>        <?php endforeach; ?>
>      </tbody>
>    </table>
>    <input type="submit" value="Update cart" />
> </form>
>
> But I need to access some more information about each CartItem to
> display in the form, such as the Producer
> ($cartItem->Harvest->Producer). But in my example, it seems that
> $cartItemForm is not an sfForm but a sfFormField. So how do I access the
> Object of a form from a form field?
>
> Any help much appreciated.
>
> Thanks
>
> Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to