S
S
Seintero2016-08-11 15:27:43
symfony
Seintero, 2016-08-11 15:27:43

How to mark existing data in output?

Hello! I have two tables, Users and Roles with a ManyToMany relationship. I just can’t figure out how to make the roles that he already has marked when displaying the user’s form for editing? Here's an example of my buildform... can't figure it out, does anyone know? :)

public function buildForm(FormBuilderInterface $builder, array $options)
    {

        $builder
            ->add('username')
            ->add('roles', EntityType::class , array(
        'class' => 'AppBundle\Entity\Roles',
                'choice_label'     => 'name',
                'multiple' => true,
                'expanded' => true,
                'mapped' => false,
    ))

        ;
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question