-
Notifications
You must be signed in to change notification settings - Fork 31
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
Drag and drop don't work #151
Comments
@rflorent hi,
About your issue: The data class does not need double backshasles. Try Does your ObjectFile entity implement Did you add any custom eventlisteners which might kick in and modify the submitted data? |
Thanks for adding code highlighting, I will use it from now. 2 NULL 17 1 542954a19e27f.pdf mydoc.pdf NULL 2014-09-29 14:46:25 2014-09-29 14:46:25 I use entitylistener on BusinessDoc to add/remove acls when owner change, that's all. This is my entity ObjectFile <?php
namespace Atm\Bundle\CoreBundle\Entity;
use Avocode\FormExtensionsBundle\Form\Model\UploadCollectionFileInterface;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\HttpFoundation\File\File;
use Atm\Bundle\CoreBundle\Entity\BusinessDoc;
/**
* @ORM\Table(name="object_file")
* @ORM\Entity()
* @Vich\Uploadable
*/
class ObjectFile implements UploadCollectionFileInterface
{
const PARENT_TYPE_BUSINESS_DOC = 1;
const PARENT_TYPE_PRESENCE = 2;
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Vich\UploadableField(mapping="object_files", fileNameProperty="path")
* @var \Symfony\Component\HttpFoundation\File\File
*/
protected $file;
/**
*
* @ORM\ManyToOne(targetEntity="ObjectFileGroup", inversedBy="objectFiles")
* @ORM\JoinColumn(name="object_group_id", referencedColumnName="id", nullable=true)
*/
protected $objectGroup;
/**
* @ORM\Column(type="integer", nullable=true)
*/
protected $parentType;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $path;
/**
* (Optional) nameable field
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $name;
/**
* (Optional) additional editable field
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $description;
/**
*
* @ORM\ManyToOne(targetEntity="BusinessDoc", inversedBy="objectFiles")
* @ORM\JoinColumn(name="business_doc_id", referencedColumnName="id")
*/
protected $businessDoc;
/**
* @var DateTime $createdAt
*
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created_at",type="datetime")
*/
protected $createdAt;
/**
* @var DateTime $updatedAt
*
* @Gedmo\Timestampable(on="update")
* @ORM\Column(name="updated_at",type="datetime")
*/
protected $updatedAt;
public function setFile(\Symfony\Component\HttpFoundation\File\File $file) {
$this->file = $file;
$this->updated = new \DateTime();
return $this;
}
public function getFile() {
return $this->file;
}
public function getSize() {
return $this->file->getFileInfo()->getSize();
}
/*
* LIEN AUTO PAR VINCH
*/
public function setParent($parent) {
$classArray = explode('\\',get_class($parent));
$className = end($classArray);
switch($className) {
case 'BusinessDoc':
$this->setBusinessDoc($parent);
$this->setParentType(self::PARENT_TYPE_BUSINESS_DOC);
break;
}
}
public function getPreview() {
return (preg_match('/image\/.*/i', $this->file->getMimeType()));
}
/**
* Set id
*
* @param string $id
* @return ObjectFile
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
public function getId() {
return $this->id;
}
public function setName($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
public function setBusinessDoc($businessDoc) {
$this->businessDoc = $businessDoc;
}
public function getBusinessDoc() {
return $this->businessDoc;
}
public function setDescription($description) {
$this->description = $description;
}
public function getDescription() {
return $this->description;
}
public function setPath($path) {
$this->path = $path;
}
public function getPath() {
return $this->path;
}
public function getMimeType() {
return $this->file->getMimeType();
}
/**
* Set parentType
*
* @param integer $parentType
*
* @return ObjectFile
*/
public function setParentType($parentType)
{
$this->parentType = $parentType;
return $this;
}
/**
* Get parentType
*
* @return integer
*/
public function getParentType()
{
return $this->parentType;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
* @return ObjectFile
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
* @return ObjectFile
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
} |
I try with this sample : https://github.com/sescandell/CollectionUploadSample/tree/master/src/Acme/DemoBundle |
@rflorent to make it clear, it only does not work when dragging and dropping the file? when selecting a file with the standard file browser it works? |
@loostro yes, it doesn't work when dragging and dropping. |
It's probably because events sent when drag'n'droping files are not the sames. I'll check that point and let you know. |
I've done more tests.
|
Hello,
I'm using this great bundle, wihtout admingenerator, and thanks for it.
I try ti use upload collection but I ran into issues.
I can drag and drop files, row are added, with preview and informations.
But files are not uploaded, data['uploads'] is always empty.
If I use file input to choose file, everything works, but I can't add more than one file.
I need somes help.
My config.yml
Entity ObjectFile
Form OjectFile
Form Parent
The text was updated successfully, but these errors were encountered: