[Hydrator] toOne with value as array from a fieldset returns null from 'missing' identifier #194

Closed
texdc opened this Issue Mar 17, 2013 · 0 comments

Comments

Projects
None yet
1 participant
Contributor

texdc commented Mar 17, 2013

In the scenario described below, the $identifiers value that is passed to find() from toOne() is an array of values from the fieldset, not one or more identifiers (although the identifier is present in the array). This causes toOne() to improperly return null instead of the matching entity.

class A
{
    /**
     * @ORM\Id @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     * @var integer $id
     */
    private $id;

    /**
     * @ORM\OneToOne(targetEntity="B", mappedBy="a", cascade={"persist", "remove"})
     * @var B
     */
    private $b;

    // ...
}

class B
{
    /**
     * @ORM\Id @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     * @var integer $id
     */
    private $id;

    /**
     * @ORM\OneToOne(targetEntity="A", inversedBy="b", cascade={"persist"})
     * @ORM\JoinColumn(nullable=false)
     * @var A
     */
    private $a;

    // ...
}

class AForm extends \Zend\Form\Form
{
    function __construct($name = 'a')
    {
        parent::__construct($name);
        $this->setObject(new A);
        $this->add(new BFieldset('b'));
    }
}

class BFieldset extends \Zend\Form\Fieldset
{
    function __construct($name = 'b')
    {
        parent::__construct($name);
        $this->setObject(new B);
        $this->add(array("name" => "id", "type" => "Zend\Form\Element\Hidden"));
        // ...
    }
}

This was referenced May 14, 2013

@texdc texdc closed this May 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment