This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
Zend\Form\Fieldset bindValues problem #83
Closed
Description
Hi.
Have next structure:
/**
* Class Client
*
* @ORM\Entity
* @ORM\Table(name="client ")
* @package Admin\Entity
**/
class Client extends AbstractEntity {
...
...
/**
* @var MasterPhotoGallery[]|ArrayCollection $photoGalleries
* @ORM\OneToMany(targetEntity="Admin\Entity\MasterPhotoGallery", mappedBy="client")
* @ZFA\Required(false)
* @ZFA\ComposedObject({
* "target_object": "Admin\Entity\MasterPhotoGallery",
* "is_collection": true,
* "options": {
* "count": 8,
* "label": "Фотогаллереи"
* }
* })
* @ZFA\Type("Zend\Form\Element\Collection")
**/
private $photoGalleries;
}
/**
* Class MasterPhotoGallery
*
* @ORM\Entity
* @ORM\Table(name="client_photo_gallery")
* @ZFA\Instance("Admin\Entity\MasterPhotoGallery")
* @ZFA\Type("Zend\Form\Fieldset")
**/
class MasterPhotoGallery extends AbstractEntity {
/**
* @var string $title
* @ORM\Column(type="string", nullable=false, length=50)
* @ZFA\Type("Zend\Form\Element\Text")
* @ZFA\Required(false)
* @ZFA\Options({
* "label": "Заголовок"
* })
**/
private $title;
...
...
...
}
On validating form, In bindValues method we have name for title in PhotoGallery class like that: "photoGalleries[0][title]". But data array has not that key. He has key title. Array values look like:
['photoGalleries' => [0 => 'title']]
Source code (after update to version 2.8.4) in Zend\Form\Fieldset, row 568-569:
foreach ($this->iterator as $element) {
$name = $element->getName(); // photoGalleries[0]['title']
if (!array_key_exists($name, $values)) { // of course key not exists
if (!($element instanceof Collection)) {
continue;
}
...
...
...
...
Source code (version 2.8.3) in Zend\Form\Fieldset:
foreach ($values as $name => $value) {
if (!$this->has($name)) {
continue;
...
Here we have correct name because it's taken from array. By the way in method extract we have same problem.
// Recursively extract and populate values for nested fieldsets
foreach ($this->fieldsets as $fieldset) {
**$name = $fieldset->getName();**