我的 i18n 学说模式和 ia 管理生成器有一个奇怪的问题。
(请先看下面的编辑部分)
架构如下所示:
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() 始终返回一个空字符串(数据库正确填充了合适的数据)。
那么,模式定义是否有些磨损?
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 名称。但在编辑视图中,我总是收到错误"widget 'name' does not exist"。
你们知道为什么会这样吗?我会非常感谢你的帮助。
编辑:
我认为问题更深层次,因为这种简单的代码和平确实有效:
首先是示例的数据集:
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
有人有什么想法吗?我真的很沮丧:(