我有两种形式:authorEdit 和 author Create。这两种形式在单个 Controller 中进行管理。每个表单都有一个提交按钮,并且这些按钮的名称不同。
如何在我的 Controller 中检查我使用的关于提交按钮名称的表单?
谢谢。
最佳答案
您可以使用 2 个不同的操作,然后调用共享方法。
/**
* ...
*/
public function createAction()
{
return $this->processForm('create');
}
/**
* ...
*/
public function editAction()
{
return $this->processForm('edit');
}
private function processForm($action)
{
// ...
return array(/* ... */);
}
关于php - Symfony2 : Two forms with a single controller (how to distinguish them with the name of the submit button),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13645872/