Category : controller

ajax displayed for me undefined when I searched a product /** * @Route("/searchProduit ", name="searchProduit") */ public function searchProduit(Request $request,NormalizerInterface $Normalizer) { $repository = $this->getDoctrine()->getRepository(Produit::class); $requestString=$request->get(‘searchValue’); $products = $repository->findProduitByName($requestString); $jsonContent = $Normalizer->normalize($products, ‘json’,[‘groups’=>’products’]); $retour = json_encode($jsonContent); return new Response($retour); } Source: Symfony4..

Read more

So I have installed ApiPlatform on my project and have a Task.php entity on it as a resource. How can I use my Task api resource’s endpoints when a form is submitted? I am considering using httpclientinterface, but there is no way to retrieve submitted values without $form->handleRequest($request) ProjectController.php public function new(HttpClientInterface $client, Request $request): ..

Read more

I am under symfony 4.4. I would like to know how to pass a variable from my controller to my formType to prepopulate a field. I searched but could not find. My controller: class TeamController extends AbstractController public function index($id,Request $request,MailerInterface $mailer) { $repo = $this->getDoctrine()->getRepository(Team::class); $team = $repo->find($id); $formcontact = $this->createForm(ConvocationType::class); $contact = $formcontact->handleRequest($request); ..

Read more

I am trying to use mailer with symfony but i got this error : The controller for URI "/register" is not callable: The "MAILER_DSN=smtp://lionel:[email protected]@gmail.com:465" mailer DSN must contain a scheme. I tried to follow the documentation. <?php namespace AppController; use AppEntityProspect; use SymfonyBundleFrameworkBundleControllerAbstractController; use SymfonyComponentMailerMailerInterface; use SymfonyComponentMimeEmail; use SymfonyComponentRoutingAnnotationRoute; class MailerController extends AbstractController { /** ..

Read more

is it correct to use repository in action? or maybe should i make another service and put it there? /** * @Route("/process/{pid}/add/dictionary/{did}", name="app_add_dictionary_to_process") * @ParamConverter("dictionary", options={"id" = "did"}) * @ParamConverter("process", options={"id" = "pid"}) */ public function addDictionaryToProcess(Process $process, Dictionary $dictionary, ProcessDictionaryRepository $repository, ProcessDictionaryLinkRegisterer $registerer) { $processDictionary = $repository->findOneBy([ ‘process’ => $process, ‘dictionary’ => $dictionary ]); ..

Read more

Using Symfony 5 I have a controller that retrieves a number of clients from the database. I would like to display these in a table. Currently my controller has this outline: public function findClients(Request $request) { // set up form if ($form->isSubmitted() && $form->isValid()) { // get array of clients from database, $clientsArray } return ..

Read more