How to display multiple values as a table in twig?

    * @Route("/list", name="list_Users")
    public function list()
        $form = $this->createFormBuilder()
            ->add('name', RangeType::class)
            ->add('age', RangeType::class)
            ->add('task', RangeType::class)

        $all_Users = $this->getDoctrine()
        if (!$all_Users) {
            throw $this->createNotFoundException(
                'database is empty or there was an error connecting to db'


        for  ($x =0; $x < count($all_Users); $x++ ){
            echo "$x";
            $tmp = $all_Users[$x]->getName();
            $tmp2 =$all_Users[$x]->getAge();
            $tmp3 = $all_Users[$x]->getTask();
            echo "$tmp ,$tmp2 , $tmp3 n";
            echo "n";


        return $this->render('User/list.html.twig', [
            'form' => $form->createView(),

I would like to display the values in tmp ,tmp2 ,tmp3 as a table using the list.html.twig file, I tried using a form to display the values but I can’t understand how to pass the values to twig file to make a table containing these values (name , age , task)

the only way i can display these values is by using echo for each value in all__users

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *