T
T
thatside2015-05-12 15:18:08
symfony
thatside, 2015-05-12 15:18:08

How to properly organize link transitions in Symfony?

It is necessary in a Symfony project to pass some specific data when following a link. The whole problem is that the links are in the table, and the transferred data (specific ID) depends on what line it is. On the one hand, it would be possible to pass this in a GET request, but this does not look like the most beautiful solution. Are there any other options?
A crutch is spinning in my head with a hidden input and a js link click handler that sets the value in the input, but this is definitely a crutch.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Pavlov, 2015-05-12
@thatside

There are several ways:

  1. standard links (get-parameters or routes):
    1.1) via get-parameters: /page?id=123&name=user
    1.2) via routes with parameters: /page/user/123 (worse: /page/name/user/id /123 or something like that)
    Describe which links you want to "decorate", maybe you can come up with something else.
    And remember that all options except the first one will not allow you to share a link normally - send a link via Skype, or put a link on another site (advertising), or even not bookmark it. Therefore, use the first method. Also, routes are the correct way to link in symfony.

K
Kir ---, 2015-05-12
@SowingSadness

Well, first you need to understand that the URL just contains certain data. Therefore, the question of how to transfer certain data using a URL is devoid of any logic.
It is also not clear what Symfony has to do with it (besides, the first one, which has long been buried in the grave).

T
tasce, 2015-05-12
@tasce

And why is a link with GET parameters not a beautiful solution, because that's what it was created for? You generate a table and add the GET parameter ?id=$id to the link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question