I need to update the budget field of my Client entity when entering new data into the Budget table. Both have relation oneToMany and manyToOne , respectively. I received suggestions to use the OO concept to do this operation, so something more or less was suggested to me:
if ($form->isValid()) {
$manager->persist($form->getData());
$manager->flush();
$Client = $manager->find('PanelBundle:Client', $form['client_id']->getData()->getId());
$Client->setBudget($manager->getRepository('PanelBundle:Budget')->getLastId());
$this->addFlash('success', 'Novo orçamento adicionado');
return $this->redirect($this->generateUrl('panel_budgets'));
}
When you see the output of $Client
, when you assign the variable the find
method, the respective name field of the id is displayed, which is the id of Client selected by select
and passed to the variable when submitting the form.
Even though there are no errors, this field is not updated when you register. I've tried another way by writing a specific function to update, looking for examples, but I got invalid semantic errors.
How can I update the budget field when executing the Budget controller's addAction
method?