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)

 if ($button->get('submit')) {
        $parameters = [];

        $clientId = $request->get('client_id');
        $clientSecret = $request->get('client_secret');
        $playlistId = $request->get('playlist_id');

        if ($clientId && $clientSecret && $playlistId) {
            $parameters['client_id'] = $playlistId;
            $parameters['client_secret'] = $clientSecret;
            $parameters['playlist_id'] = $playlistId;
        }
        Validator::validateArrayKeys($parameters);
    }

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)

  /**
 * @Route("/", name="app_index")
 */
public function index(Request $request, SubmitButton $button)
{

    $this->getParameters($request, $button);

    return $this->render('home/index.html.twig', [
        'controller_name' => 'HomeController',
    ]);
}


public function getParameters(Request $request, SubmitButton $button)
{
    $submitButton = $button->get('submit');

    dd($submitButton);

    if ($button->get('submit')) {
        $parameters = [];

        $clientId = $request->get('client_id');
        $clientSecret = $request->get('client_secret');
        $playlistId = $request->get('playlist_id');

        if ($clientId && $clientSecret && $playlistId) {
            $parameters['client_id'] = $playlistId;
            $parameters['client_secret'] = $clientSecret;
            $parameters['playlist_id'] = $playlistId;
        }
        Validator::validateArrayKeys($parameters);
    }
}

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *