OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums OroCRM OroCRM – Programming Questions get multiple files from user

This topic contains 0 replies, has 1 voice, and was last updated by  danial.sayeh.co 3 weeks, 6 days ago.

  • Creator
    Topic
  • #40755

    danial.sayeh.co
    Participant

    Sorry for my bad English.
    Im new to oro and I want to get multiple files from user in my form and persist them.
    I added my filed to my entity like this:

    I created a collection type like this:

    I added my filed to form type like this:

    After a clear cache and schema update my i went to my form page and it was great.
    Now i could use + button to add more file fileds and i could choose some files.but when i submited the form with some files (i tried it with one or more files) i got this exception:

    Fatal error: Call to undefined method Oro\Bundle\EntityConfigBundle\Config\Id\EntityConfigId::getFieldType() in /var/www/html/my_proj/vendor/oro/platform/src/Oro/Bundle/AttachmentBundle/Validator/ConfigFileValidator.php on line 64

    so I started debuging:
    i find out in ConfigFileValidator class in line 63 :

    I saw, when I was using a simple file field before the $fieldConfigId variable was of type “Oro\Bundle\EntityConfigBundle\Config\Id\FieldConfigId” class, but now when this class want to validate each files in my file collection field $fieldConfigId will be a instance of “Oro\Bundle\EntityConfigBundle\Config\Id\EntityConfigId” class which has no “getFieldType” method and this cause the problem.

    with more debuging i realized the only diference between these two validation is $fieldName, when i used a simple file field the $fieldName variable in ConfigFileValidator was name of my field in my entity but when i used a file collection filed, my field name was 0 (it used index to set field name of each file field).

    so i discovered in this method of “Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider” class :

    when the field name is a valid field name in line 7 of above code it will go to line 8 and a FieldConfigId instance will be returned but when a file in collection is validating and its field name is 0 it fail at line 7 if and because className it valid it will go to line 10 and an instance of EntityConfigId class will be returned.

    how can i solve this problem? is there any better way to do this job?

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No