一个textarea的价值,我似乎无法得到一个textarea的输入的文本。当我这样做时:如何获得在Symfony的
die($request->getPostParameter('comment'))
它输出单词“数组”。当我print_r()
它确实显示textarea是一个数组,它的值存储在数组中。但我不知道如何获得这个价值,所以我可以把它放到一个表格中的一个字段中。
@ greg0ire:我这样做是因为我想将数据保存到两个不同的表。我的html页面显示了一个实际由两个不同类/模型组成的表单。我设法将所有字段保存到除注释字段之外的两个表中。然后我试图获得价值,并意识到它是一个数组,并想知道这是不是导致我的数据不能保存的原因。这就是为什么我问这个问题。我已经问了另一个question,它解释了上下文。
这些都是在点击提交按钮
public function executeUpdateInlineForm(sfWebRequest $request)
{
$overdueInvestigation = Doctrine_Core::getTable('investigation')->find($request->getParameter('id'));
$investigationForm = new investigationInlineForm($overdueInvestigation);
$commentForm=new commentForm();
$investigationForm->bind($request->getParameter($investigationForm->getName()), $request->getFiles($investigationForm->getName()));
$commentForm->bind($request->getParameter($commentForm->getName()), $request->getFiles($commentForm->getName()));
$this->processInlineForm($investigationForm, $commentForm);
}
protected function processInlineForm(sfForm $investigationForm, sfForm $commentForm)
{
if ($investigationForm->isValid())
{
$investigation = $investigationForm->save();
$comment = $commentForm->updateObject();
$comment->setInvestigation_id($investigationForm->getObject()->getId());
$comment->setComment($commentForm->getObject()->getComment());
$comment->setuserId($investigationForm->getObject()->getCreatedUserId());
$comment->setDateEntered(time());
$comment->save();
$this->redirect('investigation/overdue/');
}
}
为什么把我的问题记下来?知道symfony和php的人看起来很容易,但我不知道! – Nicola 2011-05-11 11:31:01
1以平衡的不合理downvote – greg0ire 2011-05-11 13:03:08
可能重复的[如何从在Symfony的一种形式中更新2代表?](http://stackoverflow.com/questions/5961527/how-to-update-2-tables-from-one -form-in-symfony) – greg0ire 2011-05-11 14:25:55