Symfony Doctrine管理生成器和I18n:缓存为空时出现错误

4

我有一个奇怪的错误,在由管理生成器创建的管理模块中:我的模型具有以下架构:

StmtcHelp:
  columns:
    module: { type: string(255) }
    action: { type: string(255) }
    content: { type: string(10000) }
    translated: { type: boolean, notnull: true, default: false }
  actAs:
    Timestampable: ~
    I18n:
      fields: [content, translated]

我的generator.yml文件:

generator:
  class: sfDoctrineGenerator
  param:
    model_class:           stmtcHelp
    theme:                 admin
    non_verbose_templates: true
    with_show:             false
    singular:              ~
    plural:                ~
    route_prefix:          stmtc_help
    with_doctrine_route:   true
    actions_base_class:    sfActions

    config:
      actions:
        _delete:
          credentials: [is_super_admin]
        _new:
          credentials: [is_super_admin]
        _create:
          credentials: [is_super_admin]
      fields:  ~
      list:
        title: Inline Help
        display: [ module, action, updated_at ]
      filter:
        display: [ module, action ]
      form:    ~
      edit:    ~
      new:     ~

现在我清除缓存并加载stmtc_help/index操作,出现了以下错误:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 's.content' in 'field list'. 
Failing Query: "SELECT s.id AS s__id, s.module AS s__module, s.action AS s__action, 
s.content AS s__content, s.translated AS s__translated, s.created_at AS s__created_at, 
s.updated_at AS s__updated_at FROM stmtc_help s LIMIT 20"

看起来Doctrine没有将我的模型识别为I18n。

但如果我重新加载页面,错误就消失了,一切都正常运行。

是否有人遇到过这种问题?我错过了什么吗? 感谢任何帮助!

1个回答

2
我曾经遇到过完全相同的问题。
你在generator.yml中设置的model_class参数为stmtcHelp,但是你的模型名称为StmtcHelp(第一个字母大写)。 解决这个问题并检查routing.yml是否存在相同的问题。
在我的情况下,我只在routing.yml中拼错了模型名称,导致了相同的Column not found错误。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接