Search code examples
symfonycontrollertwigsymfony-formssymfony4

Can I use this Form in symfony 4?


I have added this form in twig, i need to know if this is okay and how can i recupere the input name="comments" in controller

                <form action="{{ path('Update') }}" method="POST">
                <input class="form-control" type="text" name="comments"
                               value=""></td>
                    <td>
                        <input type="submit" value="Save"/>
                </form>

Solution

  • You can take a look at the Symfony Request Object section of the doc:

    // retrieves $_GET and $_POST variables respectively
    $request->query->get('id');
    $request->request->get('category', 'default category');
    

    So you can retrieve in the controller as:

    $request->request->get('comments');