doctrine / doctrine-laminas-hydrator

Doctrine hydrators for Laminas applications
https://www.doctrine-project.org/projects/doctrine-laminas-hydrator.html
MIT License
33 stars 19 forks source link

Hydrating uploaded image array to entity #10

Closed mesl1012 closed 4 years ago

mesl1012 commented 4 years ago

Hello there,

In the previous zend 2 version with doctrine, i could validate a form with a file type field and it hydrates the image field with the image array. But now it seems its not doing this anymore. I am using annotation now but previously i was using yaml as my entity mapper. How can i approach this auto hydration of my objects with my forms?

public function init()
    {
        $this->setHydrator(new DoctrineHydrator($this->entityManager));
        $this->setObject(new Category());
        $this->addElements();
        $this->addInputFilter();
    }

This is how i use the hydrator with my forms..

    /**
     * @ORM\Column(name="image", type="string", length=255)
     */
    private $image;

This is how i annotate my image field

TomHAnderson commented 4 years ago

This seems to be a question for laminas form or laminas filter. The hydrator never directly acted on uploaded file data.

armenio commented 3 years ago

This seems to be a question for laminas form or laminas filter. The hydrator never directly acted on uploaded file data.

@TomHAnderson \Laminas\Filter\File\RenameUpload "return Array with tmp_name and name keys for array $value" this is processed in form validation by InputFilter, before the Hydrator See https://github.com/laminas/laminas-filter/blob/2.12.x/src/File/RenameUpload.php#L186

if you look at the hydrator's side, it makes sense that it doesn't solve this. but it also doesn't make sense to solve this "manually". or even do you have any suggestions for managing this?