Well, I have a problem using structObject, where with regard to OneToMany the edit form does not display the values of my object, I assume that this is because my other class returns a collection
This is my first class containing my folded object
<?php
namespace Nomina\Entity\Empleado;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Zend\Form\Annotation;
class Empleado2
{
private $id;
private $nombre;
private $detalles;
private $detalle;
public $submit;
public function __construct()
{
$this->detalles = new ArrayCollection();
}
public function addDetalles(Collection $detalles)
{
foreach ($detalles as $detalle) {
$detalle->setEmpleado($this);
$this->detalles->add($detalle);
}
}
public function removeDetalles(Collection $detalles)
{
foreach ($detalles as $detalle) {
$detalle->setEmpleado(null);
$this->detalles->removeElement($detalle);
}
}
public function getDetalles()
{
return $this->detalles;
}
.....
And this is my class, which can be many
<?php
namespace Nomina\Entity\Empleado;
use Nomina\Entity\Empleado\Empleado2;
use Doctrine\ORM\Mapping as ORM;
use Zend\Form\Annotation;
class EmpleadoDetalles2
{
private $id;
private $salario = '0.00';
private $banco;
private $idEmpleado;
private $empleado;
public function setEmpleado(Empleado2 $empleado = null)
{
$this->empleado = $empleado;
}
public function getEmpleado()
{
return $this->empleado;
}
I have it in my opinion
echo $this->formRow($form->get('nombre'));
echo $this->formRow($form->get('detalles')->get('salario'));
echo $this->formRow($form->get('detalles')->get('banco'));
I correctly get the field from the database, but I don’t get anything in the folded object, which in my case is "detalles", I think this is because detalles can be many objects of the same type, m not sure how to make it work.