Skip to content
Advertisement

Cannot autowire argument $of “AppControllerHomeController”: it references class “SymfonyComponentFormSubmitButton” but no such service exists

symfony noob here.

Im not sure what this autowiring error is about.

I am trying to check if a button is clicked (maybe there is a better way to do this)

Like so(see first if)

JavaScript

This is my whole class, am i referencing something wrong here ? Or is there another way to check if a form has been submitted (I dont have a database)

JavaScript

Advertisement

Answer

The problem is here:

JavaScript

Symfony can not infer what $button is. If you have a corresponding form then you should instantiate that form, handle the request and then you can check if the button was clicked, roughly like this:

JavaScript

Understandably that is a bit much if all you want to do is check if a button was clicked and you don’t want to build a whole form around this. For this you can just access the submitted data from the request without having to resort to any form class whatsover:

JavaScript

Instead of $request->request this can be $request->query if you submitted the value using GET-method, rather than post.

See also:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement