Peter Bowyer wrote:
> Currently I'm using in actions.class.php:
> $this->product_extras = 
> $q->select('p.description')->from('Product_Extras 
> p')->where('p.Product.item_code = 
> ?')->execute(array($product_id))->getFirst();
> 

In my action, I create an object if it doesn't exit.

So:

  $q = new Doctrine_Query();
  $q->select('p.description')
     ->from('Product_Extras p')
     ->where('p.Product.item_code = ?');

  $extra = $q->execute(array($product_id))->getFirst();

  if (!$extra)
  {
    $extra = new Product_extra();
  }

> And in the template:
> <?php echo textarea_tag('description', $product_extras->description); ?>
> 
> Is there any auto-fill option? This way also produces two notices 
> when used for a non-existent record - while that isn't a problem it 
> would be better if they weren't generated!


There's a fillin filter, check the manual for that.

I don't use it though.  I do something like...

executeEdit()
{

   $extra = $this->getOrCreateByProductItemCode($item_code)


   if ($this->getRequest()->getMethod() == sfRequest::POST)
   {
     $this->updateProductExtraFromRequest($extra);
   }

   $this->extra = $extra;

}

the form then posts to save... and I have this:


executeSave()
{
   $extra = $this->getOrCreateByProductItemCode($item_code);
   $this->updateProductExtraFromRequest($extra);
   $extra->save();
   $this->redirect('whereever');
}

handleErrorSave()
{
   $this->forward('extra', 'edit');
}



-- 

Ian P. Christian ~ pookey.co.uk

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" 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/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to