1

viewing this post I believe that it is possible, but i don't know how he has configured his entities.

Sonata Admin Bundle Type Collection Customisation

I have my Admin files identical to him. But these other post I found that this capability is not supported for sonata.

https://github.com/sonata-project/SonataAdminBundle/issues/262

https://github.com/sonata-project/SonataAdminBundle/issues/802

Please, could someone suggest something to figure out it!

Update: (Dour High Arch)

 .../SimBundle/Admin/EmpleadoAdmin.php
protected function configureFormFields(FormMapper $formMapper)
{
      $formMapper
        ->with('Tecnico')
           ->add('empleadoTecnico', 'sonata_type_collection'), 
                            array('edit' => 'inline','sortable'=>'pos','inline' => 'table'))
        ->end()
        ;

}

  .../SimBundle/Admin/TecnicoAdmin.php
protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
        ->add('salarioHora',null,array('label'=>'Salario por hora:'))
        ->with('Experiencia')
        ->add('experienciaLaboral', 'sonata_type_collection', array('label'=>'Experiencia Laboral:'),
                                                 array('edit' => 'inline','sortable'=>'pos','inline' => 'table'))
        ->end()


        ;   
}

   .../SimBundle/Admin/EmpExperienciaLaboralAdmin.php
protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
        ->add('nombreJefeInmediato',null,array('label'=>'Nombre Jefe Inmediato:'))      
        ;   
}

Entities

...\SimBundle\Entity;

class EmpEmpleado {

/**
 *
 * @ORM\OneToMany(targetEntity="Tecnico", mappedBy="idEmpleado", cascade={"all"}, orphanRemoval=true)
 *
 */
private $empleadoTecnico;

}

...\SimBundle\Entity;

class Tecnico {

/**
 * @var \EmpEmpleado
 *
 * @ORM\OneToOne(targetEntity="EmpEmpleado", inversedBy="empleadoTecnico")
 * @ORM\JoinColumns({
 *   @ORM\JoinColumn(name="id_empleado", referencedColumnName="id")
 * })
 */
private $idEmpleado;

/**
 *
 * @ORM\OneToMany(targetEntity="EmpExperienciaLaboral", mappedBy="idEmpleado", cascade={"all"}, orphanRemoval=true)
 *
 */
private $experienciaLaboral;

}

...\SimBundle\Entity;

class EmpExperienciaLaboral {

/**
 * @var \Tecnico
 *
 * @ORM\ManyToOne(targetEntity="Tecnico", inversedBy="experienciaLaboral")
 * @ORM\JoinColumns({
 *   @ORM\JoinColumn(name="id_empleado", referencedColumnName="id")
 * })
 */
private $idEmpleado;

}

When i'm trying add experienciaLaboral, it's faild: Fatal error: Call to a member function getName() on a non-object in

Schema looks like this:

EmpEmpleado --> (OneToMany) --> Tecnico --> (OneToMany) --> EmpExperienciaLaboral

(sorry, i can't to put the image, this my first question and I don't have 10 reputations)

Community
  • 1
  • 1
Emerson Minero
  • 583
  • 4
  • 14
  • Could you please post what you have, and what you want, to the question? We shouldn't have to chase down a bunch of external links to figure out what you want. – Dour High Arch Aug 10 '13 at 01:57
  • ok I have edited and put what I have so far @DourHighArch – Emerson Minero Aug 10 '13 at 03:36
  • I haven't touched Symfony or Sonata in a little while, but I'm pretty sure child admin is what you're looking for. Depending on what you're trying to do, sonata_type_admin might be well suited for you though. Have a look at this question: http://stackoverflow.com/questions/15629225/symfony2-1m-11-relationship-and-sonata-admin-form – Pier-Luc Gendreau Aug 10 '13 at 03:41
  • Thanks, I had already seen your article is fantastic, but I don't have a join table, that's the difference. My problem is in add Experiencia Laboral [image_problem](http://img441.imageshack.us/img441/2678/qzw7.png) – Emerson Minero Aug 10 '13 at 04:10

1 Answers1

4

No you cannot have nested collection... the limitation is due to how admin uniqid works. The unique id is used to avoid clash between element sharing the same admin.

For now adminId is not a stack, you only have adminId and childAdminId... in your case you need to have a childChildAdminId ...

rande
  • 656
  • 4
  • 5