Created
October 8, 2010 14:40
-
-
Save delbono/616895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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