Set Default value of choice field Symfony FormType

后端 未结 5 1949
野性不改
野性不改 2021-01-21 03:12

I want from the user to select a type of questionnaire, so I set a select that contains questionnaires types.

Types are loaded from a an entity QuestionType

5条回答
  •  忘掉有多难
    2021-01-21 03:52

    Set a default value on the member variable inside your entity (QuestionType), e.g.

    /**
     * default the numOfCourses to 10
     *
     * @var integer
     */
    private $numCourses = 10;
    

提交回复
热议问题