Using Symfony 5, Is there any way to avoid user edit (using browser inspector) on hidden input field?
My use case is:
My website can display to a user A a list of recommended user. For each recommend user displayed, the user A can click on a recommended user to send him a message.
To do that, I am generating a specific form for each recommended users and the form contains an hidden input field with the recommended user ID as value, and a submit button to send the message.
I would like to ensure that the user A do not change the input hidden field in order to contact a user which is not recommended. To do that, I am checking on server side, when the form is sent, that the user id in the form sent is an ID of a recommend user. It is working but I would like to avoid this double check on my side.
Nevertheless, as I am already using CSRF default protection, do you know if Symfony could do that natively? I mean to ensure that this hidden input field has not been changed by the user? By configuring a parameter for this HiddenType field?
Because as I am already using CSRF protection, symfony guarantee the security (against CSRF attacks) when I use $myForm->isValid(). I guess Symfony is storing the CSRF token somewhere... So we could imagine Symfony could store solewhere HiddenType fields that we could flagged as "not-changable". And the $myForm->isValid() could check CSRF token validity as usual + hiddenType field flagged as "not-changable".
What do you think about it? This feature already exists? Is it a good idea? New potential feature?