Reputation: 11
I work with Symfony 2.4, KnpLabs DoctrineBehaviors bundle for translation in database, and A2LiX Translation Form for fields translation.
Form display and insertion in database work fine but errors for translation fields are not printed.
For example :
Post.php
/**
*
* @ORM\Column(name="photo", type="string", length=255)
* @Assert\NotBlank(message="no photo")
*/
private $photo;
PostTranslation.php
/**
*
* @ORM\Column(name="title", type="string", length=255)
* @Assert\NotBlank(message="no title")
*/
private $title;
PostType.php
$builder
->add('translations', 'a2lix_translations')
->add('photo')
->add('submit', 'submit');
form.html.twig
<form method="post" novalidate {{form_enctype(form)}}>
<p>{{ form_widget(form.translations) }}</p>
<p>{{ form_label(form.photo, 'photo') }}<br />{{ form_widget(form.photo) }}</p>
<p>{{ form_widget(form.submit) }}</p>
<p>{{ form_widget(form._token) }}</p>
<p>{{ form_errors(form.translations) }}</p>
<p>{{ form_errors(form.photo) }}</p>
<form>
When i submit the form, i have this Thanks for your help
Upvotes: 1
Views: 767
Reputation: 17181
To do it inside YAML configuration, you can do this:
CRMPicco\GolfBundle\Entity\CourseGuide:
properties:
name:
- NotBlank: ~
translations:
- Valid: ~
Upvotes: 0
Reputation: 6708
First update to the last version of A2lixTranslationFormBundle. And check that you have well in your Post entity, the @Assert\Valid annotation on the $translations field.
See http://symfony.com/doc/current/reference/constraints/Valid.html
use Symfony\Component\Validator\Constraints as Assert;
/**
* @Assert\Valid
*/
protected $translations;
Upvotes: 1