Issue 1:
Most of the times, you define your validation rules inside of your Entities.

Some Forms require only a subset of data that your Entity contains, forcing you to create FormModels and copying Validator rules from one place to the code.

As everybody knows, copying means trouble and duplication, which means that if an update happens only at one location, you have an inconsistency in your code. In this situation, it'll be a missing validation rule.

To mitigate this problem, Symfony Validator component should have an ability to "import" validation rules from another location (class/property). Example:

class UserUpdateFormModel
{
/**
* We only allow user name updates.
*
* @Assert\Import(from="@ICUserProfileBundle:User", property="name")
*/
protected $name;
}

It seems to be possible already, since ClassMetadata in the validator component already has a mergeConstraints() function. What do you guys think?

Issue 2:
Hi guys,

Following my discussion with leonardo I implemented a form to create a new Translation linked to an existing TranslationToken or a new one (with some ajax). For now let's focus on the case where TranslationToken exists in DataBase.

Here is my relationship inside Translation class :

@ORM\ManyToOne(targetEntity="ACME\MyFirstBundle\Entity\TranslationToken")
@ORM\JoinColumns({
@ORM\JoinColumn(name="translation_token_id", referencedColumnName="id", nullable=false)
})
private $translationToken;

Here's how I embed a list of existing TranslationToken in my Translation Form :

->add('translationToken', 'entity', array(
'label' => 'translation.translationtoken.label',
'class' => ACMEMyFirstBundle:TranslationToken',
'property' => 'name',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('tt')
->orderBy('tt.name', 'ASC');
},
'required' => false
))

So the form works fine, TranslationToken are listed correctly and TranslationToken is well attached to Translation upon $form->getData() AND after em->persist($translation) in controller :

$translation ACME\MyFirstBundle\Entity\Translation
id integer 16
language string "en"
domain string "messages"
message string "TEST"
translationToken ACME\MyFirstBundle\Entity\TranslationToken
id string "1"
name string "menu.home"

Although I select an existing TranslationToken I get the following error (maybe because the id is a string, but it's not up to me...)...

A new entity was found through the relationship 'ACME\MyFirstBundle\Entity\Translation#translationToken' that was not configured to cascade persist operations for entity: ACME\MyFirstBundle\Entity\TranslationToken@000000005b1c6e850000000070a7ede3. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'PUC\LibBundle\Entity\TranslationToken#__toString()' to get a clue.

But if I persist manually the TranslationToken object or via cascade={"persist"} it would try to INSERT a new TranslationToken in database whereas the idea is to connect the existing one to my Translation record obviously... Something you see as being wrong ? I deeply looked over the web, posted on the mailing list but nothing helped... To me it's not logical.

BTW : $form->isValid() gives back an error as well for the joined field without deep details. I don't know why.

Thanks for your time and consideration.