I have this view:
//login.html.twig
You should pass the Request object to the action method then deal with it:
public function conectionAction(Request $request){
if ($request->getMethod() == Request::METHOD_POST){
$user = $request->request->get('user');
$password = $request->request->get('password');
}
}
However I suggest you to use the Symfony Form Component to dial with this situation.
Try this, by way of example and using Symfony2.8
View:
<form action="{{ path('connection') }}" method="post" name="formulario_login">
<label for="username">User:</label>
<input type="text" id="username" name="_username" value="" />
<br />
<label for="password">Password:</label>
<input type="password" id="password" name="_password" />
<br />
<input type="checkbox" id="remember_me" name="_remember_me"/>
<label for="remember_me">Remember me</label>
<br />
<input type="submit" name="login" value="Login" />
</form>
Controller:
public function connectionAction(Request $request) {
$username = $request->request->get('_username');
$password = $request->request->get('_password');
....
}
Other way to get parameters, as you can see the naming is not all that intuitive:
// $_GET parameters
$request->query->get('name');
// $_POST parameters
$request->request->get('name');