Symfony 1.4:Doctrine I18Nジェネレーターの問題
-
30-09-2019 - |
質問
i18nの教義スキーマと管理者ジェネレーターには奇妙な問題があります。
(最初に下の編集部分をご覧ください)
スキーマは次のように見えます:
CargoSize:
connection: doctrine
actAs:
Timestampable: ~
I18n:
fields: [name, linkname, seoname, description]
tableName: com_cargo_size
columns:
id: { type: integer(11), notnull: true, unsigned: true, primary: true, autoincrement: true }
name: { type: string(50), notnull: true }
linkname: { type: string(100), notnull: true }
seoname: { type: string(100), notnull: true }
description: { type: string(255), notnull: true }
私がSFFormsで最初に抱えている問題:
new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false), array('style' => 'list-style-type: none; display: inline;'))
これにより、正しいIDを使用してラジオブタンセットが生成されますが、空の名前の値が生成されます。 IDとLANGでCargosizeオブジェクトを直接選択して名前の値を取得しようとする場合でも、getName()は常に空の文字列を返します(DBは適切なデータで正しく入力されます)。
Somethngはスキーマの定義ですり減っていますか?
2番目の問題は、管理者のジェネレーターに表示されます。
php symfony doc:generate-admin --module=cargo_size admin CargoSize
Generator.ymlは次のように見えます:
generator:
class: sfDoctrineGenerator
param:
model_class: CargoSize
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: cargo_size
with_doctrine_route: true
actions_base_class: sfActions
config:
actions: ~
fields: ~
list:
display: [name, lang]
filter: ~
form: ~
edit:
display: [name]
new: ~
面白いことに、リストビューにi18nの名前が表示されているということです。しかし、編集ビューでは、常にエラーが発生します 「ウィジェットの名前」は存在しません」.
なぜこれが起こるのか分かりますか?私はあなたの助けにとても感謝しているでしょう。
編集:
この単純な平和は機能しているので、問題はより深くなっていると思います。
最初に例のデータセット:
cargo_size
id created_at updated_at
1 2010-04-22 21:37:44 2010-04-22 21:37:44
cargo_size_translation
id name linkname seoname description lang
1 klein klein klein klein de
1 small small small small en
$c = Doctrine::getTable('CargoSize')->findOneBy('id', 1);
echo $c; // (toString exists)
// Output: Catchable fatal error: Method CargoSize::__toString()
// must return a string value in
// /var/www/.../apps/frontend/modules/start/templates/indexSuccess.php on line 1
echo $c->getName();
// Output: nothing
誰かが何かアイデアを持っていますか?私は本当に脱皮しています:(
解決 2
バグを見つけました。何らかの理由で、文化は「de_de「de」の代わりに。この設定では、i18nの動作はうまくいきませんでした!
他のヒント
最初の問題:
表示される「名前値」は、__toString()メソッドの結果から取得されます。このような「メソッド」オプションを追加できます。
new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false, 'method' => 'getName'), array('style' => 'list-style-type: none; display: inline;'))
2番目の問題:
フォームはi18nフォームを埋め込む必要があります。これを行うには、これを構成メソッドに入れます。
$this->embedI18n($cultures);
ここで、$文化はあなたの文化コードの配列です。