My problem is, that symfony only inserts the last entry in the foreach loop and not all entries.
In my example, only Test 2 will be inserted.
My code: information: $_POST['title'] = Test, Test
$_POST['number'] = 1, 2
$titles = $_POST['title'] ?? [];
$numbers = $_POST['number'] ?? [];
foreach ($titles as $key => $title) {
$product->setNumber($numbers[$key]);
dump($numbers[$key]);
$product->setTitle($title);
dump($title);
$em->persist($product);
}
$em->flush();
Screenshot of my dump: