I've been working on a menu in my site for a while and I've been asking a lot of question about this menu. The idea is that my menu have a select with all my project and clicking my modify or delete button while do¸what it needs to do with the selected project.
So far, I found two possible ways to do this:
-Do a form with a select and three buttons (add, modify, delete)
-Do a link for each button and generate the select in twig with a loop
I think that the more logical option would be the second one, but the problem is that my link must send the id of the selected project.
Since twig generate the html for you, once it's generated, twig cannot it again, so I can't say to twig to change the link according to my selected project!
I know that there must be a way to solve this with Javascript, but, really, I would rather prefer using a form insteed, heaven if it would seems kind of weird in this situation, because the form already knows which project is selected and it's easy to use the controller to redirect on the next page for the modify button and delete the project.
If the link to the page would change, I would need to change my javascript which is something that wouldn't happen with my oder sollution.
So, is there an other way to still make what I want with links without some javascript? If not, I'll just take my other solution.
Aucun commentaire:
Enregistrer un commentaire