OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce Probleme with File type in frontend form build

This topic contains 2 replies, has 2 voices, and was last updated by  msalmi.kais 6 years ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #32932

    msalmi.kais
    Participant

    Hello,
    I added fields to the entity customer in Entity Management (SpgFormeJuridique: string and SPGRegistreCommerce: File)

    in frontend:
    I created a bundle to edit the customer’s information:

    SpgCustomerUserType.php:

    SpgCustomerType.php

    when I submit the form I receive an error in log file:

    request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\ORMInvalidArgumentException: “Expected value of type “Oro\Bundle\AttachmentBundle\Entity\File” for association field “Oro\Bundle\CustomerBundle\Entity\Customer#$SPGRegistreCommerce”, got “Symfony\Component\HttpFoundation\File\UploadedFile” instead.” at C:\EasyPHP-Devserver-17\eds-www\oro-commerce\vendor\doctrine\orm\lib\Doctrine\ORM\ORMInvalidArgumentException.php line 206 {“exception”:”[object] (Doctrine\\ORM\\ORMInvalidArgumentException(code: 0): Expected value of type \”Oro\\Bundle\\AttachmentBundle\\Entity\\File\” for association field \”Oro\\Bundle\\CustomerBundle\\Entity\\Customer#$SPGRegistreCommerce\”, got \”Symfony\\Component\\HttpFoundation\\File\\UploadedFile\” instead. at C:\\EasyPHP-Devserver-17\\eds-www\\oro-commerce\\vendor\\doctrine\\orm\\lib\\Doctrine\\ORM\\ORMInvalidArgumentException.php:206)”} []

    Thanks for your help

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #32933

    Dmitriy Pasechnik
    Participant

    Hi msalmi.kais

    Try to change SpgCustomerType.php row 30
    From FileType::class
    To \Symfony\Component\Form\Extension\Core\Type\FileType::class

    Just note, that in case you created those fields via Entity Management
    you actually don’t need to create any new form types for customer`s entity.

    You can use standard \Oro\Bundle\CustomerBundle\Form\Type\CustomerType
    instead of yours custom SpgCustomerType

    Those additional fields will be automatically added into \Oro\Bundle\CustomerBundle\Form\Type\CustomerType
    if you set ‘Show On Form’ checkbox during new field creation in Entity Management

    #32934

    msalmi.kais
    Participant

    Hi Dmitriy Pasechnik
    I change the class SpgCustomerUserType.php

    I receive an error in log file:

    request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\ORMInvalidArgumentException: “Expected value of type “Oro\Bundle\UserBundle\Entity\User” for association field “Oro\Bundle\AttachmentBundle\Entity\File#$owner”, got “Oro\Bundle\CustomerBundle\Entity\CustomerUser” instead.” at C:\EasyPHP-Devserver-17\eds-www\oro-commerce\vendor\doctrine\orm\lib\Doctrine\ORM\ORMInvalidArgumentException.php line 206 {“exception”:”[object] (Doctrine\\ORM\\ORMInvalidArgumentException(code: 0): Expected value of type \”Oro\\Bundle\\UserBundle\\Entity\\User\” for association field \”Oro\\Bundle\\AttachmentBundle\\Entity\\File#$owner\”, got \”Oro\\Bundle\\CustomerBundle\\Entity\\CustomerUser\” instead. at C:\\EasyPHP-Devserver-17\\eds-www\\oro-commerce\\vendor\\doctrine\\orm\\lib\\Doctrine\\ORM\\ORMInvalidArgumentException.php:206)”} []

    but when i add the file in the backend, and in the front i edit the form and i upload another file, it works !!!
    so, if the field is empty it returns error
    do I forget an aption?
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)

The forum ‘OroCommerce’ is closed to new topics and replies.

Back to top