Remove _construct method. You don't need it.
ContextErrorException when submit form with A2lix
-
11-10-2022 - |
Question
For a multilingual form I use Gedmo Translatable combined with A2lix and I use personal translations, so for 1 entity I have 1 translation : Categ and CategTranslation.
To show the form everything is alright, but when I submit it I've this error :
ContextErrorException: Warning: Missing argument 1 for Immo\AnnonceBundle\Entity\CritereCategTranslation::__construct(), called in /var/www/kimsufi/asimmobilier/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/DataMapper/GedmoTranslationMapper.php on line 70 and defined in /var/www/kimsufi/asimmobilier/src/Immo/AnnonceBundle/Entity/CritereCategTranslation.php line 29
This is my 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.')
)
)
)
)
)
);
My 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;
}
Any idea ? Thanks
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow