Doctrine で Symfony 1.2 を使用しています。2 つの言語に翻訳された Place モデルがあります。この Place モデルには、ネストされたセットの動作もあります。
別のノードに属する新しい場所を作成する際に問題が発生しています。2 つのオプションを試しましたが、どちらも失敗します。
1 オプション
$this->mergeForm(new PlaceTranslationForm($this->object->Translation[$lang->getCurrentCulture()]));
フォームをマージすると、place_id フィールド ID の値が配列になります。IDを持つ実際のオブジェクトを待っているためだと思います。place_id='' を設定しようとすると、別のエラーが発生します。
2 オプション
$this->mergeI18n(array($lang->getCurrentCulture()));
public function mergeI18n($cultures, $decorator = null)
{
if (!$this->isI18n())
{
throw new sfException(sprintf('The model "%s" is not internationalized.', $this->getModelName()));
}
$class = $this->getI18nFormClass();
foreach ($cultures as $culture)
{
$i18nObject = $this->object->Translation[$culture];
$i18n = new $class($i18nObject);
unset($i18n['id']);
$i18n->widgetSchema['lang'] = new sfWidgetFormInputHidden();
$this->mergeForm($i18n); // pass $culture too
}
}
エラーは次のとおりです。
Couldn't hydrate. Found non-unique key mapping named 'lang'.
SQLを見ると、IDが定義されていません。したがって、重複レコードになることはありません(一意のキー(id、lang)があります)
何が起こっている可能性がありますか?
ありがとう!