Open rpostolov opened 9 years ago
@sescandell Could you take a look? I've not used Async upload yet.
I had a little look to this file : C:\wamp\www\Tranoi-Symfony\vendor\avocode\form-extensions-bundle\Avocode\FormExtensionsBundle\Form\EventListener\CollectionUploadSubscriber.php
In this file i have this bloc (that correspond with the option 'nameable' int he config for collection_upload:
if ($this->nameable || $this->editable) {
// Handle additional uploaded data on AsyncUpload
foreach ($this->uploads as $uploadKey) {
if (array_key_exists($uploadKey, $data)) {
$this->additionalContentUploads[$uploadKey] = $data[$uploadKey];
unset($data[$uploadKey]);
}
}
}
Here is th configuration:
addFormOptions:
primary_key: id
nameable: false
editable: [ legende ]
And looking here :
https://github.com/loostro/FormExtensions/blob/master/Form/EventListener/CollectionUploadSubscriber.php
the bloc is missing.
Someone can help please ?
same problem. It's because $data is empty. $data only contains uploads key and is unset after setting var uploads.
$this->uploads = $data['uploads'];
unset($data['uploads']);
...
array_key_exists($uploadKey, $data)
Editable : additionnal fields are not rendered
Hi there,
Sorry for the long silence,
@rpostolov : could you please show me your code? I'm using this component and it's working pretty well. Maybe you're in a different context than mine and we don't really handle it in the right way.
Here is some of my code:
// From the FormType
$builder->add('medias', 'afe_collection_upload', array(
'primary_key' => 'pathHashed',
'label' => false,
'sortable' => false,
'nameable' => false,
'editable' => $options['with_description'] ? array('description') : array(),
'allow_add' => true,
'allow_delete' => true,
'type' => 'my_custom_form_media',
'uploadRouteName' => 'async_upload',
'autoUpload' => $options['auto_upload'], // true in my configuration
'options' => array(
'data_class' => Media::class,
'media_type' => Media::PICTURE,
'for_library' => true,
'with_description' => $options['with_description']
)
));
Avocode form extension configuration:
avocode_form_extensions:
twig:
use_form_resources: false
upload_manager: vich_uploader
collection_upload:
async_listener_enabled: true
async_route_name: async_upload
Actually... nothing very special... maybe main point is I have a "entity in the middle" between my collection and my medias. My model is the following:
Product has one Library Library has many medias My sample code form below is part of the LibraryType used inside my ProductType
Maybe with some of your code, we can identify what's not working in your situation,
By the way, did you also check sample here: https://github.com/sescandell/CollectionUploadSample
there is a long time it didn't have been updated, but it should still be working.
Hi everyone !
I'm using avocode and vich_uploader with admingenerator to make collection_upload.
I have the form for collection upload , but i have this error when i want to save my uploaded files :
ContextErrorException: Warning: array_key_exists(): The first argument should be either a string or an integer in C:\wamp\www\Tranoi-Symfony\vendor\avocode\form-extensions-bundle\Avocode\FormExtensionsBundle\Form\EventListener\CollectionUploadSubscriber.php line 130
Do someone have an idea ?
Thanks and good day :)