Symfony 2 Create a entity form field with 2 properties Symfony 2 Create a entity form field with 2 properties php php

Symfony 2 Create a entity form field with 2 properties


Yes, define a getUniqueName() method in the entity class like:

public function getUniqueName(){    return sprintf('%s - %s', $this->name, $this->value);}

And edit the property form option:

'property' => 'childEntity.uniqueName',

You also can omit the property option and define the __toString() method same way in order to not repeat the setting of the property option in every form.