Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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