//MenuCardTable.class
public function getMenuCardForCombo(){
$q = Doctrine_Query::create()
->select('m.*')
->from('MenuCard m');
$results = $q->execute();
foreach($results as $menu){
$choice[$menu->getId()] = $menu->getName();
}
return $choice;
}
====================no funciona para validar "required"=========================================
//DishesForm.class
$choices =
array('Seleccione un item') + Doctrine::
getTable('MenuCard')->
getMenuCardForCombo();
$this->
widgetSchema['menu_card_id'] =
new sfWidgetFormSelect
(array('choices' =>
$choices));
$this->
validatorSchema['menu_card_id'] =
new sfValidatorChoice
(array('choices' =>
array_keys($choices)));
====================otro metodo: validar "required"=========================================
//el item x defecto sera en blanco (poner 'add_empty true')
//BasesDishesForm.class
'menu_card_id' =>
new sfWidgetFormDoctrineChoice
(array('model' =>
'MenuCard',
'add_empty' =>
true)),
//DishesForm.class
$this->validatorSchema['menu_card_id']->setOption('required', true);
Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1897"></script>
0 comment about "colocar un item por defecto a un combo relacionado"