php - Symfony2 : Two forms with a single controller (how to distinguish them with the name of the submit button)

标签 php post button symfony

我有两种形式: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/

相关文章:

javascript - sendBeacon JSON 数据未读取(服务器端)Nodejs 和 JS

php - 对象无法使用 AJAX 正确发布

python - 更改 Bokeh 按钮的颜色?

android - 无法解析属性 "src"中的可绘制对象

php - 解析我无法识别为对象、数组或 Json 的字符串

php - 无法在 C :\wamp\www\zr\core\functions\users. php 中重新分配自动全局变量 _POST

javascript - 在 JavaScript 中从 Bytes 下载文件

android - 拖动和按下按钮 - android

php - 产品网格中的自定义 SQL

security - phpinfo() 中 display_errors 中的标准输出是什么意思?