Reputation: 830
part of my code in listForm.class.php:
public function configure() {
$list_id = $this->getOption('list_id');
$endkunde_id = $this->getOption('endkunde_id');
$shopname_id = 1;
$todoWrapperForm = new sfForm();
$todoWrapperForm = new sfForm();
//$todos = Doctrine_Core::getTable('Todo')->findAll();
//$todos = Doctrine_Core::getTable('EinkaufslisteElemente')->findAll();
$todos = Doctrine_Core::getTable('EinkaufslisteElemente')
->createQuery('ee')
->where('ee.einkaufsliste_id = ?', $list_id)
->innerJoin('ee.Einkaufsliste e')
->andWhere('e.shopname_id = ?', $shopname_id)
->innerJoin('e.EinkaufslisteEndkunde ek')
->execute();
foreach ($todos as $todo) {
$todoWrapperForm->embedForm($todo->getId(), new EinkaufslisteElementeForm($todo));
}
$todoWrapperForm->embedForm('new_1', new EinkaufslisteElementeForm()); // add one blank todo to start
$this->embedForm('todos', $todoWrapperForm);
$this->list = new sfWidgetFormTextarea(array(), array('rows' => '10', 'cols' => '35'));
$this->mergePostValidator(new sfValidatorDoctrineUnique(array('model'=>'todo', 'column'=>'task'), array('required' => false))) ;
$this->widgetSchema->setNameFormat('todo_list[%s]');
}
I want to create an extra field from 'Customer' with his name which is not hidden, and I want to create an input field hidden with the list_id from the table 'List'. How can I do it with embedForm?
Upvotes: 0
Views: 204
Reputation: 22756
Inside your listForm
, just add at the bottom of your configure:
$this->widgetSchema['list_id'] = new sfWidgetFormInputHidden();
// do not forget to add the propel validator (ie: the one that can check if `list_id` is ok - like in the database)
$this->validatorSchema['list_id'] = new sfValidatorPass();
Then, in your action, don't forget to set a default to list_id
:
$form = new listForm();
$form->setDefault('list_id', $list_id);
Upvotes: 2