[FLOW3-general] Problem With Update Action

daniel andrew daniel.andrew91 at gmail.com
Mon Apr 2 13:29:04 CEST 2012


Hello,

I have a problem with update in flow3. Basicly i have 2 tables in MySql.
The first table called translatiounit and it has fields: translationsource,
translationkey, translationpackage. The second table called
translationtarget and it has fields: translationtarget,
translationlanguage, translationapproval, comment, translationunit.

The problem is, i have to update those fields from different table in 1
form. How to do that? should i create new method in the repository or is
there any other better way to do that?  this is my code in controller to do
update:

/**
 * create action
 * @param \Somea\Translation\Domain\Model\TranslationUnit $unit A new unit
to add
         * @param \Somea\Translation\Domain\Model\TranslationPackage
$package A new Package to add
         * @param \Somea\Translation\Domain\Model\TranslationLanguage
$language A new Language to add
         * @param string $translationTarget
         * @param string $translationApproval
         * @param string $comment
 * @return void
 */
public function updateAction(TranslationUnit $unit, TranslationPackage
$package, TranslationLanguage $language, $translationTarget,
$translationApproval, $comment) {
                $this->translationUnitRepository->update($unit);
                $targetObject  = new Translationtarget();
                $targetObject->setTranslationTarget($translationTarget);
                $targetObject->setTranslationApproval($translationApproval);
                $targetObject->setComment($comment);
                $targetObject->setTranslationLanguage($language);
                $targetObject->setTranslationUnit($unit);
                $this->translationTargetRepository->update($targetObject);

$this->redirect('index','TranslationUnit','Somea.Translation',array('language'
=> $language, 'package' => $package));

}

if i execute this action, it will throw an error: *: The object of type
"TranslationTarget" given to update must be persisted already, but is new*

Please let me know if there is any questions about my explanation or you
need something else.

Best Regards,

Daniel


More information about the FLOW3-general mailing list