如何在 symfony 4 中显示带有从关系数据库中获取的数据的表单作为下拉列表?

How to display a form with data fetched from a relational database as dropdown in symfony 4?

指导我在 symfony 4 中使用从关系数据库中获取的数据进行下拉的建议

推荐link:

Relational Database

在控制器中

添加这一行

$category = $this->getDoctrine() ->getRepository(Category::class) ->findAll();

在树枝中

Add these lines in your twig