Reputation: 600
I want to edit(update) some field in database from form without using form builder in symfony 2.4, for example i have id, username, password, first_name,last_name, ...., added, updated, in this case i just want to update, first_name, last_name and updated field.
could you give some idea how to update only some field in symfony.
Thank You in Advance.
Upvotes: 1
Views: 497
Reputation: 2285
You can find your user details by find()
method by using doctrine entity manager
$id = /* user id that you want to edit/update*/
$em = $this->getDoctrine()->getManager();
$userEntity = $em->getRepository('YourBundle:Users')->find($id);
Then use setter methods for updating values
$userEntity->setFirstName('new first name');
$userEntity->setLastName('new last name');
$userEntity->setUpdates('updated name or date');
$em->persist($userEntity);
$em->flush();
this will update you user data
Upvotes: 2