0

I want to create a form in a symfony2 project that redirects to the same page after being processed. However I'm currently receiving always NULL when reading the request $parameters whenever the form is being submitted.

The controller:

public function formAction(Request $request)
{
    $parameters = $request->request->all();
    var_dump($parameters);

    return array();
}

The twig template:

...
<form action="" method="post">
    <input type="text" id="username" placeholder="Enter username">
    <button type="submit" class="btn btn-default">Submit</button>
</form>
...
2
  • 1
    You should add a name attribute to your input field. Commented Mar 9, 2015 at 10:33
  • That was indeed the problem. May be you could write it as an answer so I can accept it? Commented Mar 9, 2015 at 10:37

1 Answer 1

1

You just need to add a name attribute to your input field:

<input type="text" id="username" name="username" placeholder="Enter username">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.