0

I Have this code, that must update object in DB with data from form, but it says that i must use setId() instead of direct changind property "ID". But i need to get "ID" from hiding field from previous form. How can i get that works?

        $rPhone = new RejectedPhone();
        $em = $this->getDoctrine()->getEntityManager();
        $repository = $em->getRepository("TelnetSmsBundle:RejectedPhone");

        $addRPhoneForm = $this->createFormBuilder($rPhone)
                ->add('id', 'hidden')
                ->add('phone', 'text', array("label" => "Номер телефона (обязательно через 7-ку!):"))
                ->add('description', 'textarea', array("label" => "Описание:"))
                ->getForm();

        $addRPhoneForm->bindRequest($request);

        var_dump($rPhone); exit();

        $em->flush();
1
  • Ok, i add SetId() to my Entity's class, error dissapear, but it still don't upgrade record Commented Feb 16, 2012 at 8:54

1 Answer 1

1

I think you need this:

$addRPhoneForm ->setData($rPhone);

I think you forgot the persist method:

$em->persist($rPhone);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.