Skip to content

Instantly share code, notes, and snippets.

@delbono
Created October 8, 2010 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delbono/616895 to your computer and use it in GitHub Desktop.
Save delbono/616895 to your computer and use it in GitHub Desktop.
<?php
class OrdinativiOrderItemFoodForm extends OrdinativiOrderItemForm
{
public function configure()
{
$this->removeFields();
//$this->widgetSchema['item'] = new sfWidgetFormInputHidden();
$this->widgetSchema['order'] = new sfWidgetFormInputHidden();
$foods = $this->getOption('foods');
$ordered_items = $this->getOption('ordered_items');
if($ordered_items){
foreach($ordered_items as $oitem){
$day[$oitem->getDayId()][$oitem->getMenuItemId()] = $oitem->getOrderItemQty();
}
}
if($foods){
foreach($foods as $food){
$itemDays = $food->getMenuItemDays();
foreach($itemDays as $item){
$elName = 'item['.$food->getDay().']['.$item->getId().']';
$this->widgetSchema[$elName] = new sfWidgetFormInputText(array(), array('size'=>2));
$this->setValidator($elName, new sfValidatorInteger( array('required' => false) ));
if(empty($day[$food->getDay()][$item->getId()])){
$day[$food->getDay()][$item->getId()] = 0;
}
$this->setDefault($elName, $day[$food->getDay()][$item->getId()]);
$weeks[$food->getWeek()][$food->getDay()][] = $item;
}
}
}
$this->setDefault('order', $this->getOption('order'));
$this->setValidator('order', new sfValidatorInteger(array('required' => 'The order id field is required')) );
//$this->setValidator('item', new sfValidatorInteger(array('required' => false)) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment