【发布时间】:2015-07-28 03:25:28
【问题描述】:
我尝试设置翻译表格
http://a2lix.fr/bundles/translation-form/ 和https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/translatable.md#translatable-entity-example
作曲家.json
"a2lix/translation-form-bundle": "2.*@dev",
"stof/doctrine-extensions-bundle": "1.2.*@dev",
config.yml
stof_doctrine_extensions: default_locale: zh 形式: 默认: 可译:真 sluggable:真 sluggable:真 可时间戳:真
a2lix_translation_form:
locale_provider: default # [1]
locales: [pl, en, de] # [1-a]
default_locale: en
manager_registry: doctrine # [2]
templating: "A2lixTranslationFormBundle::default.html.twig"
实体
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Table(name="c_Base"
,indexes={
* @ORM\Index(name="search_name", columns={"name"}),
* @ORM\Index(name="orderCity", columns={"city"})
* })
*/
class Base implements Translatable{
/**
* @ORM\Column(type="bigint")
* @ORM\Id
*/
private $id;
/**
* Hexaid
* @var string
*/
private $hid;
/**
* @ORM\Column(type="string")
* @GRID\Column(title="name")
* @Gedmo\Translatable
* @var string
*/
private $name;
/**
* @Gedmo\Locale
* Used locale to override Translation listener`s locale
* this is not a mapped field of entity metadata, just a simple property
*/
private $locale;
构建表格
公共函数 buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('translations', 'a2lix_translations', array(
'fields'=>array(
'name'=>array(),
'description'=>array(
'field_type' => 'ckeditor'
)
)
)
);
错误
Neither the property "translations" nor one of the methods "getTranslations()", "translations()", "isTranslations()", "hasTranslations()", "__get()" exist and have public access in class "Mea\CharterBundle\Entity\Base".
我没有私人 $translations; var in base - 因为是公共翻译 - 例如个人翻译存在 $translations https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/translatable.md#personal-translations
我可以在http://a2lix.fr/bundles/translation-form/ 中使用它吗?
【问题讨论】:
-
来自 Atlantic18 的 DoctrineExtensions 更难使用,最好使用来自 KNP 的 DoctrineExtensions。如果你愿意,我可以举个例子。
-
请显示示例,也许我改变了我失去了很多时间 - 我回到旧版本 Atlantic18 并且它工作但有时会生成未定义的索引:foreignKey
-
如果你有有趣的例子,是的。它有一些表单扩展来编辑翻译?
标签: php symfony doctrine-extensions