Вопрос

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