vitiko / IphpFileStoreBundle

Symfony 2 file upload for doctrine entities
http://symfonydev.ru/iphpfilestorebundle/
51 stars 23 forks source link

Validation problem #6

Closed getme closed 7 years ago

getme commented 11 years ago

One more issue

/**
* @FileStore\Uploadable()
**/
class VehicleCat
{
   /**
     * @var string
     *
     * @ORM\Column(name="image", type="array", nullable=true)
     * @FileStore\UploadableField(mapping="vehicle_cat")
     * @Assert\File(maxSize="20M")
     */
    private $image;

}

// MyFormType.php
$builder->add('vehicle_cat', 'entity', array(
    'class' => 'MyBundle:VehicleCat',
));

Throws

Expected argument of type string, array given

in vendor/symfony/symfony/src/Symfony/Component/Validator/Constraints/FileValidator.php at line 80

I know that's because MyFormType has cascade_validation set to true and VehicleCat gets validated. any solutions? Thanks

LouTerrailloune commented 11 years ago

I had the same problem when using a FormType that does not contain the file field. This was solved by using validation groups.

korol-sas commented 8 years ago

please get example for fix this problem