-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Collection Upload] Undefined variable: editable #12
Comments
Hi @ksn135 This is probably because you don't go through https://github.com/symfony2admingenerator/FormExtensionsBundle/blob/master/Form/EventListener/CollectionUploadSubscriber.php#L174 I don't have immediately time to check for it. Maybe later today or next week (working on AdminLTE in priority :) ). But if you can find what's wrong and make a PR, that would be great ! Question: do you have the same issue with the "legacy" bundle? |
What is the "legacy" bundle ? You mean AvocodeFormExtensionsBundle ? |
Yes... the current one is still unstable and in active development |
My bad, production project already running on it |
Well, I try to get it fixed by myself |
Here is some CollectionUpload I'm using in a production project working well: $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_project_media',
'uploadRouteName' => 'async_upload',
'autoUpload' => $options['auto_upload'],
'options' => array(
'data_class' => Media::class,
'media_type' => Media::PICTURE,
'for_library' => true,
'with_description' => $options['with_description']
)
)); Could you please show us the generated Form? Thank you, |
Thank you very much for your help!
And my form class:
|
This is your I assume you are not in a "async" mode, am I right? So basically, your fix might be wrong in async mode for example (I'm not sure, there is a long time I worked on that part, I could double check what I'm saying if you want). I think the right fix should be something like: if ($this->allow_add) {
// create file entites for each file
$editable = array(); // Prevent strange behavior... or don't define it and so Exception will be thrown meaning the user mis-configured its form?
foreach ($this->uploads as $index => $upload) {
if (!is_object($upload) && !is_null($this->storage)) {
// read submitted editable
$editable = $this->editable[$upload];
$upload = $this->storage->getFile($upload);
} elseif (array_key_exists($index, $this->editable)) {
$editable = $this->editable[$index];
} Not sure at all about it. |
My mistake, in my sample project, I'm not using the editable param... I should make an example... |
With my fix it works in both modes. If you return back my uncommented line you've got undefined index error, My autogenerated form type for CabinetCategory:
|
OK... I'll take a look later, if it works for now for you, it's okay 👍 |
No, async mode IS NOT working in my case. It's problem with folder permissions in MAC OS X: http://stackoverflow.com/questions/16378828/result-of-sys-get-temp-dir-not-writable-by-apache-processs-user . |
Well, javascript just remove uploaded file row from DOM on "delete" button and then on "save" send empty form. CollectionUploadSubscriber can't do anything because it dosen't recieve expected "delete_uploads" key in empty data array. Moving on... May be just piece of Javascript code just dissapers ? Or may be it's again something wrong in my case, don't know / |
Did you try the other bundle: https://github.com/symfony2admingenerator/AvocodeFormExtensionsBundle ? |
Hi, I have the same problem with editable :
Was it fixed ? Thanks |
Hi, I have the same problem too, with field editable : Thanks ! |
I have encountered the same issue. My fix is as follows (Starting in line 174 in CollectionUploadSubscriber.php):
I don't know exactly how this works but I assumed that on first upload (synchronous) there are objects in $upload and then the variable §editable will never be set. And when it is set, it has to be an array. Please fix this soon. I would do this on my own but I'm not quite sure if my solution is best. It works though (at least for me but there is a chance to break async mode with my modifiaction) ;) In fact $editable has to be a multidimensional array (see foreach call), maybe there is some more work to do to clean it up. Greetings. |
@tknuppe For me your code works with the following changes: |
I'm on dev-master.
In vendor/symfony2admingenerator/form-extensions-bundle/Admingenerator/FormExtensionsBundle/Form/EventListener/CollectionUploadSubscriber.php at line 192
My config:
My entity (almost the same as from example: https://github.com/symfony2admingenerator/FormExtensionsBundle/blob/master/Resources/doc/collection-upload/overview.md):
The text was updated successfully, but these errors were encountered: