0 votes

Making a @Gedmo\Locale field in translatable entity should by implemented in version 3.2.7.1319 (according your comment). So how to use it?

enter image description here

After export to ORM i get this:

<?php

namespace AlagenexBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;

/**
 * @ORM\Entity
 * @ORM\Table(name="category")
 */
class Category implements Translatable
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="SEQUENCE")
     * @ORM\SequenceGenerator(sequenceName="category_id_seq")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=100, nullable=false)
     * @Gedmo\Translatable
     */
    private $label;

    /**
     * @ORM\Column(nullable=true)
     */
    private $locale;
}

First problem is that locale field has no @Gedmo\Locale annotation. Second is that it has @ORM\Column annotation. What am i doing wrong?

asked in General Questions by (200 points)

2 Answers

0 votes

Can you please be more specific in your question?

Are you trying to create Locale variable (non-orm) or field (orm)?

if non-orm, remove it from field list and enter it only to Gedmo\Locale property as stirng

answered by Skipper developer (135k points)
0 votes

Hi, I tested it in the office and here is step-by-step how to configure it properly

enter image description here

Fill property Locale with string "locale" (type it), but don't create Locale field in entity.

and after export you will get

<?php
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

/**
 * @ORM\Entity
 */
class SampleEntity
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Gedmo\Translatable
     */
    private $name;

    /**
     * @Gedmo\Locale
     */
    private $locale;
}

Here is a testing Skipper project: https://support.skipper18.com/?qa=blob&qa_blobid=15863976045259084745

answered by Skipper developer (135k points)

Yes, this solution works. It has never occured to me that i could type in the field, because of the combobox to choose from existing fields. Thanx.

You're right. It's a exception because of this non-orm field