我正在使用symfony 1,问题是当我使用RenderPartial函数弹出窗口小部件时,我收到以下错误:
注意:未定义的变量:表格在第49行的...... templates / template.php中 致命错误:在第49行的/ / templates / template.php中的非对象上调用成员函数open()
这是我在class.php中的功能:
public function executeProduct(sfWebRequest $request)
{
$this->renderPartial('integrate/Product');
$form = new ProductForm();
if ($request->isMethod('post') && $request->hasParameter($form->getName()))
{
$form->bindRequest($request);
if ($form->isValid())
{
$form->save();
return $this->redirectBack();
}
$this->forms['product'] = $form;
}
else
{
foreach ($form->getGlobalErrors() as $nom=>$error)
{
echo $nom.':'.$error;
}
}
}
我能做些什么来解决这个问题?
答案 0 :(得分:0)
不,不幸的是这种方法错了,我必须放if ($request->isMethod('post'))
我修改了我的模板:
<form action="<?php echo url_for('integrate/Product') ?>" method="POST">
<ul>
<ul> <li> <?php echo $form['name']->label()?> </li>
<?php echo $form['name']->field()?>
</ul>
所有街区:
if ($request->isMethod('post') && $request->hasParameter($form->getName()))
如果我删除它,它可以工作,但我必须把它,所以在这改变之后;我有这个错误:
注意:未定义的变量:第49行的...... templates / template.php中的表单 致命错误:在第49行的/ / templates / template.php中的非对象上调用成员函数label()
答案 1 :(得分:0)
渲染局部时,必须手动提供变量。尝试
$this->renderPartial('integrate/Product', array('form' => $form));
并在操作结束时移动电话。