1

我有一个奇怪的问题,我的i18n教义架构和i.a.管理生成器。Symfony 1.4:Doctrine 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用正确的数据正确填充)。

那么是模式定义的一些worng?

第二个问题似乎与管理发电机:

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:  ~ 

有趣的是,该列表视图显示我的国际化名称。但在编辑视图中,我总是得到错误“小部件名称”不存在“

你们有什么想法为什么发生这种情况?我会非常感谢你的帮助。

编辑:

我认为这个问题坐镇更深,因为这个简单的代码和平做笔记的工作:

首先,数据集的例子:

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 

是否有人有任何想法?我真的deperated :(

回答

1

我发现了这个错误。出于某种原因,文化被设置为“de_DE”而不是“de”。 使用此设置i18n行为的东西没有工作!

2

第一个问题:

从__toString()方法的结果采取 您可以添加“方法”选项,这样显示“名称值”。

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

问题二:

你的表格必须嵌入国际化表单要做到这一点,把这个配置方法:。

$this->embedI18n($cultures); 

其中$文化是您的文化代码的数组。

+0

这很有趣,我已经有了toString。但是现在在添加embedI18n之后,所有问题似乎都可以解决,不仅在sfForm中,而且在O_o的独立位置也是如此。所以thx很多这个提示:) – ownking 2010-09-02 10:32:53

+0

这个问题仍然存在,我不知道为什么,但是当我想获得名称属性: $ cargo_size-> getName(); //(这些值在每个语言的DB中) 它返回一个空字符串。 你有更多的想法可能是什么问题? – ownking 2010-09-03 13:09:15