Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
texdc opened this Issue · 0 comments

1 participant

@texdc

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
@texdc texdc closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.