V
V
vladislav9972021-06-09 14:37:01
symfony
vladislav997, 2021-06-09 14:37:01

Why are values ​​not written to the intermediate table, although all links are registered?

Tell me why the values ​​​​are not written to the intermediate table, although all the links are registered, and also from the view, if you dump it, do all the fields come?

There is a Many-to-Many relationship between Chat & Group entities.

There is a ChatType.php form

->add('groups', EntityType::class, array(
                'class'     => Group::class,
                'expanded'  => true,
                'multiple'  => true,
                'choice_label' => 'getTitle',
            ))


and there is a controller ChatController.php
$chat = $em->getRepository(Chat::class)->findOneBy(['id' => $id]);

        $form = $this->createForm(ChatType::class, $chat);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em->persist($chat);
            $em->flush();

            return $this->redirectToRoute('chats');
        }


And the problem is that all the fields that arrive and are written to the chat table, but nothing is written to the intermediate one, what could be the problem and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Derepko, 2021-06-09
@vladislav997

https://www.doctrine-project.org/projects/doctrine...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question