问题
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