I have an autogenerated form, that extends BaseFormDoctrine. What I want is to initialize this form in an action and pass to the template as a variable. The problem is that form requires certain object to be passed. How to do this?

有帮助吗?

解决方案

If you don't pass any argument to form you will get form which will add new object. If you pass argument you will get form which will edit object

So you need to pass instance of object you want to edit. Something like this should do the thing

$objectEntity = Doctrine_Core::getTable("TABLENAME")->findOneBy("id",$idOfYourObject);
$this->form = new YourFormClass($objectEntity);

Because you use $this->form this will be available in template file as $form variable, all you have to to is

<?= $form ?>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top