Symfony POST variable always empty

不羁岁月 提交于 2020-01-04 14:18:56

问题


Here is my Symfony controller:

class MyPageController extends Controller
{
    public function indexAction(Request $request)
    {
        $postData = $request->request->get('manage');
        return new Response('<html><body>Post: '.$postData.'!</body></html>');
    }
}

Here is my HTML:

<form action="/..." method="POST" id="entity">
    <input type="text" value="This is the value" id="manage" />
    <input type="submit" class="button" value="Submit" />
</form>

$postData is always empty.

I've tryed also:

$postData = $request->request->get('entity');

$postData['manage'] is empty too!

Can somebody help me?


回答1:


i guess it's not a symfony issue, just html, your input needs name attribute so it can be included in POST

<form action="/..." method="POST" id="entity">
<input type="text" value="This is the value" name="manage" />
<input type="submit" class="button" value="Submit" />
</form>


来源:https://stackoverflow.com/questions/12022166/symfony-post-variable-always-empty

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!