How to set default value for form field in Symfony2?

后端 未结 22 1770
暖寄归人
暖寄归人 2020-11-27 13:23

Is there an easy way to set a default value for text form field?

22条回答
  •  无人及你
    2020-11-27 13:58

    If your form is bound to an entity, just set the default value on the entity itself using the construct method:

    public function __construct()
    {
        $this->field = 'default value';
    }
    

提交回复
热议问题