-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Hello,
I am tryin to buid a form that allows user to add an image collection to an entity.
Entity property :
/**
* @ORM\OneToMany(targetEntity="PropertyImage", mappedBy="property", orphanRemoval=true, cascade={"persist", "remove"})
*/
protected $pics;
Entity propertyImage :
/**
* @var int
*
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @Assert\File(
* maxSize="20M"
* )
* @Vich\UploadableField(mapping="property_file", fileNameProperty="fileName")
*/
protected $file;
/**
* @ORM\Column(name="file_name", type="string", nullable=true)
*/
protected $fileName;
/**
* @ORM\ManyToOne(targetEntity="Property", inversedBy="pics")
* @ORM\JoinColumn(name="property_id", referencedColumnName="id")
*/
protected $space;
So I have a formType for property which is :
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
/// ... some property form fields ...
->add('pics', 'afe_collection_upload', array(
'type' => new ImageType(),
'nameable' => false,
'allow_add' =>true,
'maxNumberOfFiles' => 5,
'options' => array(
'data_class' => "AppBundle\Entity\PropertyImage"
)
))
;
}
And the ImageType is basically simple :
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id')
->add('fileName')
->add('file')
;
}
And here are the results:
My problem is:
When I click "Add Files" I have a file browser that allow me to select a file, the file shows up, no problem.
But when I click again on Add Files to select a second file, the second file replace the first. instead of adding to the queue :
The behavior I expect is : when I click on add file, a new row appear to allow me to select an additionnal file. Instead of replacing the first one.
any idea ?
Thanks
Metadata
Metadata
Assignees
Labels
No labels