Reputation: 159
I would like know if is possible to add my form a field that it's not passed with referenced. This is code:
RetiroResiduo Entity:
class RetiroResiduo
{
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity="GestionResiduos\SolicitudRetiroBundle\Entity\SolicitudRetiro")
* @ORM\JoinColumn(name="numeroSolicitudRet_id", onDelete="CASCADE", referencedColumnName="numeroSolicitudRet")
*/
protected $numeroSolicitudRet;
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity="GestionResiduos\ResiduoBundle\Entity\Residuo")
* @ORM\JoinColumn(name="siglaRepresentativa_id", onDelete="CASCADE",referencedColumnName="siglaRepresentativa")
*/
protected $siglaRepresentativa;
Residuo Entity:
class Residuo
{
/**
* @ORM\Id
* @ORM\column(type="string", length=6)
*/
protected $siglaRepresentativa;
/**
* @Assert\NotBlank()
* @ORM\column(type="string", length=150)
*/
protected $nombreResiduo;
my form is:
class RetiroResiduoType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('siglaRepresentativa')
....
So, siglaRepresentativa in my form is shows select dropdown and only have 3 characters. I would like to show the field nombreResiduo from Residuo Entity instead. I am new in symfony and probably this is solved easily. I hope your advices! grettings
Upvotes: 1
Views: 101
Reputation: 345
See http://symfony.com/doc/current/reference/forms/types/entity.html#choice-label for docs.
$builder->add('siglaRepresentativa', EntityType::class, array(
'class' => 'YourBundle:Residuo',
'choice_label' => 'nombreResiduo',
));
Upvotes: 1