How to set a default value in a Symfony 2 form field?

前端 未结 2 966
-上瘾入骨i
-上瘾入骨i 2020-12-12 03:44

I\'ve been trying to set up a form with Symfony 2.

So I followed the tutorial and I\'ve created a special class for creating the form and handling the

2条回答
  •  半阙折子戏
    2020-12-12 04:05

    What you're trying to do here is creating a security hole: anyone would be able to inject any ID in the user_product_id field and dupe you application. Not mentioning that it's useless to render a field and to not show it.

    You can set a default value to user_product_id in your entity:

    /**
     * @ORM\Annotations...
     */
    private $user_product_id = 9000;
    

提交回复
热议问题