我正在努力使用“sonata_type_translatable_choice”字段类型。
PageAdmin.php:
protected function configureFormFields(FormMapper $formMapper) {
$formMapper
->with('page.title', ['class' => 'col-md-12'])
->add('name', null, ['label' => 'page.field.name'])
->add('code', null, ['label' => 'page.field.code'])
->add('content', 'ckeditor', ['label' => 'page.field.content'])
->add('status', 'sonata_type_translatable_choice', [
'choices' => Page::$statuses,
'catalogue' => 'admin',
'label' => 'page.field.status'
])
->end()
;
}
Page.php:
public static $statuses = array(
self::STATUS_HIDDEN => 'page.status.hidden',
self::STATUS_OFFLINE => 'page.status.offline',
self::STATUS_DRAFT => 'page.status.draft',
self::STATUS_ONLINE => 'page.status.online'
);
admin.en.yml:
page:
status:
hidden: hidden
offline: offline
draft: draft
online: online
表单显示的选择字段的值为:“page.status.hidden”而不是位于我的.yml文件中的“hidden”。
有人可以帮我这个吗?