Handling Multiple File Uploads in Sonata Admin Bundle

SonataAdminBundle file upload: Error

"any infos on this topic"
Have you seen http://symfony.com/doc/current/cookbook/form/form_collections.html ?

You should embed image form into the parent form. For instance,

->add('myImage','collection',array('type'=>new MyImageType()))

Instead of putting multiple image1, image2,... make another form class, eg. MyImageType() and add it as a collection type in to an existing form.

Work in that direction, good luck.

Symfony Sonata AJAX image multi-upload

So I endedup using Valumns Ajax multi uploader: http://valums.com/ajax-upload/

I tried to customize the Sonata Admin Page but this proved a bit difficult, Instead I simply created a route / controller / view specifically for uploading batch images. It seems to be working great!

Error uploading file using Sonata Admin and Doctirne

The problem is that you never call the upload method of your entity.

Add the following methods to your admin class (sonata) :

/**
* Handles file upload on create.
*
* @param object $created The newly created entity
*/
public function prePersist($created)
{
$created->upload();
}

/**
* Handles file upload on update.
*
* @param object $updated The updated entity
*/
public function preUpdate($updated)
{
$updated->upload();
}

And it should works.

This will call the upload method of your entity before persist/update it.

See the corresponding part of the Sonata File upload recipe.



Related Topics



Leave a reply



Submit