This topic contains 2 replies, has 2 voices, and was last updated by msalmi.kais 5 years, 6 months ago.
-
Topic
-
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:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051class SpgCustomerUserType extends AbstractType{const NAME = 'spg_customer_frontend_customer_user_profile';/*** @var string*/protected $dataClass;/*** @param string $dataClass*/public function setDataClass($dataClass){$this->dataClass = $dataClass;}/*** @param FormBuilderInterface $builder* @param array $options*/public function buildForm(FormBuilderInterface $builder, array $options){$builder->add('Customer', new SpgCustomerType());}/*** {@inheritdoc}*/public function configureOptions(OptionsResolver $resolver){$resolver->setDefaults(['data_class' => $this->dataClass,'intention' => 'frontend_customer',]);}/*** @return string*/public function getName(){return $this->getBlockPrefix();}/*** {@inheritdoc}*/public function getBlockPrefix(){return self::NAME;}}SpgCustomerType.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960class SpgCustomerType extends AbstractType{const NAME = 'spg_customer';/*** @param FormBuilderInterface $builder* @param array $options*/public function buildForm(FormBuilderInterface $builder, array $options){$builder->add('name','text',['required' => true,'label' => 'Libilé'])->add('SpgFormeJuridique','text',['required' => true,'label' => 'Forme Juridique'])->add('SPGRegistreCommerce',FileType::class,['required' => true,'label' => 'Registre de commerce']);}/*** {@inheritdoc}*/public function getName(){return $this->getBlockPrefix();}/*** {@inheritdoc}*/public function getBlockPrefix(){return self::NAME;}public function configureOptions(OptionsResolver $resolver){$resolver->setDefaults(array('data_class' => 'Oro\Bundle\CustomerBundle\Entity\Customer',));}}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
The forum ‘OroCommerce’ is closed to new topics and replies.