Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Post-Parameters as Action Input

I get the following error message after submitting a form:

Controller "Foo\ModelBundle\Controller\PostController::createAction()" requires that you provide a value for the "$title" argument (because there is no default value or because there is a non optional argument after this one).

The form is not created by the symfony framework form feature, its just plain html in the twig template:

<form action="{{ path('post') }}" method="post">
        Title: <input name="title"><br>
        Author: <input name="author"><br>
        Content: <input name="content"><br>
        <input type="submit">
</form>

This is the routing information for the post route:

post:
        pattern:        /post
        defaults:       { _controller: FooModelBundle:Post:create }
        requirements:
                _method:        POST

This is the defintion of the create action:

public function createAction($title, $author, $content) {

The symfony profiler for the request shows me, that $title, $author and $content is set to the correct values.

What is the correct way to provide the action with the needed parameters?

Shouldn't they populated by the framework with the values in the POST request?

I'm using symfony 2.0 PR 10.

Crossposted this also here: http://forum.symfony-project.org/viewtopic.php?f=23&t=34427

like image 760
echox Avatar asked Nov 29 '25 01:11

echox


1 Answers

I've tried to answer this for you where you originally posted the question at http://forum.symfony-project.org/viewtopic.php?f=23&t=34427&p=115961#p115961

The ideas is to use the form generation features of the framework and retrive the data via the request object.

I hope you'll find it very helpful.

like image 113
jfgrissom Avatar answered Nov 30 '25 13:11

jfgrissom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!