What I am trying to do is to get an Id from a folder number. Both my Id and my folder number (folder number is unique) are in the same controller.
I get the folder number from a text input and I then need to redirect the user to a page /Id.
My question is how should I handle it ?
Do I need to create a method getIdFromFolderNumber() in my controller and then call this function in my JS function ? Or maybe do I need to do everything in a JS function (I know I need a JS function since I will use an AJAX request to redirect my user and to get the value from the input).
I don't need the code or anything, I just want to know the method I need to use to understand how to do it. I've started working on a very big project and since I am a junior developer I am a bit lost.
Thank you for your help.
You don't need any JS to achieve that. It's a simple form and redirection.
Once your form which gives you the number is submitted :
$number = $form->get('number')->getData();
Then you got your criteria for your doctrine request :
$id = $yourEntityRepository->findBy(['number' => $number)])->getId();
Now you have your ID for the redirection :
return $this->redirectToRoute('entity_show', ['id' => $id]);
IS that what you were looking for ?
Note : you don't need to store $number and $id as variables. It was only to make it clear. You can replace them by the actual requests where it's needed.