0
使用Symfony我在后端创建了一个表单。我有一个提交按钮,用于保存表单。我需要添加另一个链接(除了提交按钮)到应该发送表单数据的提交按钮的表单。通过这个链接,我将通过控制器中的另一种方法处理提交的数据。Symfony将表单数据转换为链接提交中的sfRequest
我试过link_to('Link', '/backend_dev.php/question/edit?id='.$question->getId(), array('post' => true))
和link_to('Link', '/backend_dev.php/question/edit?id='.$question->getId(), array('method' => 'post'))
,但这些函数不发送表单数据。
控制器在链路onClick事件,这将改变形式的action
属性,并提交
public function executeSave(sfWebRequest $request)
{
$this->form = new SomeForm(SomePeer::retrieveByPk($request->getParameter('id')));
if($request->isMethod('post'))
{
$this->form->bind($request->getParameter('some'), $request->getFiles('some'));
if ($this->form->isValid())
{
$some = $this->form->save();
$this->redirect('some/edit?id='.$some->getId());
}
}
}
public function executeLink(sfWebRequest $request)
{
// Like executeSave I need form data here
}
为什么你要链接提交表单?这是提交按钮的工作...... – j0k
我需要通过两种不同的方法提交表单和处理提交的数据的功能。所以我使用提交按钮,并尝试为其他提交链接。 – mert