多言語フォームの場合、Gedmo Translatable をA2lixと組み合わせて使用し、個人的な翻訳を使用するため、1 つのエンティティに対して、Categ と CategTranslation の 1 つの翻訳があります。
フォームを表示するにはすべて問題ありませんが、送信すると次のエラーが発生します。
ContextErrorException: 警告: /var/www/kimsufi/asimmobilier/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/DataMapper/ で呼び出される Immo\AnnonceBundle\Entity\CritereCategTranslation::__construct() の引数 1 がありませんGedmoTranslationMapper.php の 70 行目で、/var/www/kimsufi/asimmobilier/src/Immo/AnnonceBundle/Entity/CritereCategTranslation.php の 29 行目に定義されています
これは私の CategType です:
->add('translations', 'a2lix_translations_gedmo', array(
'translatable_class' => 'Immo\AnnonceBundle\Entity\CritereCateg',
'locales' => array('fr', 'en'),
'required' => false,
'fields' => array(
'libelle' => array(
'field_type' => 'text',
'locale_options' => array(
'en' => array(
'label' => 'Libellé du critère (en) :',
'attr' => array('placeholder' => 'Example : Convenience, proximity, etc.')
),
'fr' => array(
'label' => 'Libellé du critère (fr) :',
'attr' => array('placeholder' => 'Exemple : A proximité, commodités, etc.')
)
)
)
)
)
);
私の CritereCategTranslation :
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation;
/**
* @ORM\Entity
* @ORM\Table(name="criterecateg_translations",
* uniqueConstraints={@ORM\UniqueConstraint(name="lookup_unique_idx", columns={
* "locale", "object_id", "field"
* })}
* )
*/
class CritereCategTranslation extends AbstractPersonalTranslation
{
/**
* Convenient constructor
*
* @param string $locale
* @param string $field
* @param string $value
*/
public function __construct($locale, $field, $value)
{
$this->setLocale($locale);
$this->setField($field);
$this->setContent($value);
}
/**
* @ORM\ManyToOne(targetEntity="CritereCateg", inversedBy="translations")
* @ORM\JoinColumn(name="object_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $object;
}
何か案が ?ありがとう