I have set the personal traslation table with this article
I have a table 'AttrSchool' which has column named 'description' to be translated into three language en,ja,th.
and translated text are stored in AttrSchoolTranslation
Now I made the form to edit and update the 'AttrSchool' data.
public function editAttrSchoolAction(Request $request,$schoolId){
$em = $this->getDoctrine()->getManager();
$repository = $em->getRepository('UserBundle:AttrSchool');
$attrSchool = $repository->findOneBy(array('id' => $schoolId));
foreach ($attrSchool->getTranslations() as $trans){
if($trans->getLocale() == 'ja'){
$desc_ja = $trans->getContent();
}
if($trans->getLocale() == 'th'){
$desc_th = $trans->getContent();
}
}
$form = $this->createFormBuilder($attrSchool)
->add('description','textarea',array('required'=> false,'attr' => array('rows' => '8','cols' => '60')))
->add('description_th','textarea',array('required'=> false,'data'=> $desc_th,'mapped' => false,'attr' => array('rows' => '8','cols' => '60')))
->add('description_ja','textarea',array('required'=> false,'data'=> $desc_ja,'mapped' => false,'attr' => array('rows' => '8','cols' => '60')))
$form->handleRequest($request);
if ($form->isValid()) {
$attrSchool->setDescription($form->get('description_en')->getData());
$attrSchool->addTranslation(new \Acme\UserBundle\Entity\AttrSchoolTranslation('ja','description',$form->get('description_ja')->getData()));
$attrSchool->addTranslation(new \Acme\UserBundle\Entity\AttrSchoolTranslation('th','description',$form->get('description_th')->getData()));
However it looks very clumsy. and it inserts the new AttrSchoolTranslation column, not update. (That's of course because I called new \Acme\UserBundle\Entity\AttrSchoolTranslation.....)
however I don't know how to update the data in the translation table.
Does any one know the hint??