1

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には適切なデータが正しく入力されています)。

それで、スキーマ定義で何かが摩耗していますか?

2番目の問題は、admin-generatorで発生します。

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

誰かが何か考えを持っていますか?私は本当に必死です:(

4

2 に答える 2

2

最初の問題:

表示される「名前の値」は、__ toString()メソッドの結果から取得されます。次のような「メソッド」オプションを追加できます。

new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false, 'method' => 'getName'), array('style' => 'list-style-type: none; display: inline;'))

2番目の問題:

フォームにはi18nフォームを埋め込む必要があります。これを行うには、これをconfigureメソッドに入れます。

$this->embedI18n($cultures);

ここで、$culturesはカルチャコードの配列です。

于 2010-08-29T11:09:04.433 に答える
1

バグを見つけました。何らかの理由で、カルチャは単に「de」ではなく「 de_DE 」に設定されました。この設定では、i18nの動作は機能しませんでした。

于 2010-09-05T21:01:33.513 に答える