Internationalization Symfony 1.4:原则i18n生成器问题

Internationalization Symfony 1.4:原则i18n生成器问题,internationalization,symfony1,doctrine,symfony-1.4,admin-generator,Internationalization,Symfony1,Doctrine,Symfony 1.4,Admin Generator,我的i18n条令模式和I.a.管理生成器有一个奇怪的问题 (请先查看下面的编辑部分) 模式如下所示: CargoSize: connection: doctrine actAs: Timestampable: ~ I18n: fields: [name, linkname, seoname, description] tableName: com_cargo_size columns: id:

我的i18n条令模式和I.a.管理生成器有一个奇怪的问题

(请先查看下面的编辑部分)

模式如下所示:

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 }
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:     ~
我对sfForms的第一个问题:

new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false), array('style' => 'list-style-type: none; display: inline;'))
php symfony doc:generate-admin --module=cargo_size admin CargoSize
这将生成一个具有正确ID但名称值为空的无线电接口集。 即使我试图通过直接按ID和LANG选择CargoSize对象来获取名称值,getName()也总是返回空字符串(数据库中正确填充了合适的数据)

那么,架构定义是否存在问题

管理生成器出现第二个问题:

new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false), array('style' => 'list-style-type: none; display: inline;'))
php symfony doc:generate-admin --module=cargo_size admin CargoSize
generator.yml看起来像:

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 }
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名称。但在编辑视图中,我总是得到错误“widget'name'不存在”

你们知道为什么会这样吗?我将非常感谢你的帮助

编辑:

new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false), array('style' => 'list-style-type: none; display: inline;'))
php symfony doc:generate-admin --module=cargo_size admin CargoSize
我认为问题更深层,因为这种简单的代码和平确实有效:

首先是示例的数据集:

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

有人知道吗?我真的很依赖:(

第一个问题:

new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false), array('style' => 'list-style-type: none; display: inline;'))
php symfony doc:generate-admin --module=cargo_size admin CargoSize
显示的“名称值”取自_toString()方法结果。 您可以添加“方法”选项,如下所示:

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

new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false), array('style' => 'list-style-type: none; display: inline;'))
php symfony doc:generate-admin --module=cargo_size admin CargoSize
您的表单必须嵌入i18n表单。为此,请将其放入configure方法中:

$this->embedI18n($cultures);

其中$cultures是您的区域性代码数组。

我发现了错误。出于某种原因,区域性被设置为“de_de”而不仅仅是“de”。
有了这个设置,i18n行为的东西就不起作用了!

这很有趣,我已经有了toString。但是现在在添加Embeddei18n之后,所有的问题似乎都解决了,不仅在sfForm中,在form independet places中也是如此。因此,这个提示非常有用:)问题仍然存在,我不知道为什么,但是当我想用:$cargo_size->getName();//(每个语言的值都在DB中)它返回一个空字符串。你有更多的想法是什么问题吗?