/** * @Route("/", name="index") * @Route("/s/{query}", name="search") */ public function indexAction(Request $request, $query = null, $sid = null, $key = null) { if ($sid && $key) { $captcha = [ 'captcha_sid' => $sid, 'captcha_key' => $key ]; } $form = $this->createFormBuilder() ->add('search', TextType::class) ->getForm(); $form->handleRequest($request); $VKAPI = $this->get('vk_music'); dump($request); if (isset($query)) { //$form->get('search')->setData($query); if ($sid && $key) { $tracks = $VKAPI->search($query, $captcha); } else { $tracks = $VKAPI->search($query); } } else { if ($sid && $key) { $tracks = $VKAPI->getPopular($captcha); } else { $tracks = $VKAPI->getPopular(); } } dump($tracks); if (isset($tracks['error'])) { $errorInfo = $tracks['error']; $params = [ 'sid' => $errorInfo['captcha']['sid'], 'img' => $errorInfo['captcha']['img'] ]; if (isset($query)) { $params['query'] = $query; } return $this->forward('MusicBundle:Default:captcha', $params); } else { return $this->render('MusicBundle:Default:index.html.twig', [ 'form' => $form->createView(), 'tracks' => $tracks ]); } } /** * @Route("/captcha") */ public function captchaAction(Request $request, $sid, $img, $query = null) { $form = $this->createFormBuilder() ->add('key', TextType::class) ->add('sid', HiddenType::class, ['data' => $sid]) ->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $data = $form->getData(); $params = [ 'sid' => $data['sid'], 'key' => $data['key'] ]; if (isset($query)) { $params['query'] = $query; } return $this->forward('MusicBundle:Default:index', $params); } else { return $this->render('MusicBundle:Default:captcha.html.twig', [ 'form' => $form->createView(), 'captcha_img' => $img ]); } } 

I open site / app_dev.php / s / text, displays captcha. I write it, submichu, and the page is infinitely loaded. I understand that everything goes into a cycle. And in fact, I do not understand anything. If you need someone to provide pieces of service - write. But here everything seems to be clear how it works.

  • And how did you understand that it goes into a cycle? PHP logs have errors? - Vadim Bondarenko
  • Purely I assume that leaves in a cycle. 1) If from index to forward on captcha, where there is a form. And if you add it, and back it up on Index, and if there is a form in the index, and if you change it (let's say data substitute), then the symphony scold that the form is addled and you change the data. I guess something is wrong with forward forms with active forms. 2) There are no errors in the logs - iSize1ce

0