Skip to content

Instantly share code, notes, and snippets.

@manuakasam
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save manuakasam/1ac71daf7269616f55f0 to your computer and use it in GitHub Desktop.
Save manuakasam/1ac71daf7269616f55f0 to your computer and use it in GitHub Desktop.
\Zend\Debug\Debug::dump($request->getFiles()->toArray()['incident']['attachedFiles']);die();
array (size=3)
0 =>
array (size=5)
'name' => string 'GON.PNG' (length=7)
'type' => string 'image/png' (length=9)
'tmp_name' => string 'D:\DevBox\php_tmp\phpA7F2.tmp' (length=29)
'error' => int 0
'size' => int 4099156
1 =>
array (size=5)
'name' => string '1498520.jpg' (length=11)
'type' => string 'image/jpeg' (length=10)
'tmp_name' => string 'D:\DevBox\php_tmp\phpA803.tmp' (length=29)
'error' => int 0
'size' => int 293815
2 =>
array (size=5)
'name' => string '10014654_710780645639034_820628453_n.jpg' (length=40)
'type' => string 'image/jpeg' (length=10)
'tmp_name' => string 'D:\DevBox\php_tmp\phpA804.tmp' (length=29)
'error' => int 0
'size' => int 45509
<?php
public function indexAction()
{
$request = $this->getRequest();
if($request->isPost())
{
$post = array_merge_recursive(
$request->getPost()->toArray(),
$request->getFiles()->toArray()
);
$this->incidentForm->setData($post);
if($this->incidentForm->isValid()) {
\Zend\Debug\Debug::dump($this->incidentForm->getData());
die();
}
}
return [
'form' => $this->incidentForm
];
}
<?php
$singleFileFilter = new InputFilter();
$singleFileFilter->add(
[
'name' => 'attachment',
'required' => false,
'filters' => [
[
'name' => 'filerenameupload',
'options' => [
'target' => '/data/incident_attachments/',
'randomize' => true,
'use_upload_name' => false,
'overwrite' => false
]
]
]
]
);
$attachedFilesFilter = new CollectionInputFilter();
$attachedFilesFilter->setInputFilter($singleFileFilter);
$this->add($attachedFilesFilter, 'attachedFiles');
<?php
$fileElement = new Element\File('attachment');
$fileElement->setOptions(
[
'label' => 'Add Attachment',
'label_attributes' => [
'class' => 'control-label col-sm-3'
]
]
);
$fileElement->setAttributes([
'class' => 'form-control'
]);
$this->add(
[
'name' => 'attachedFiles',
'type' => 'collection',
'options' => [
'count' => 3,
'target_element' => $fileElement
]
]
);
object(Krankikom\Entity\Incident)[467]
protected 'id' => null
protected 'logDate' => null
protected 'incidentTime' =>
object(DateTime)[730]
public 'date' => string '2014-05-15 02:55:39' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Berlin' (length=13)
protected 'incidentLocation' => null
protected 'incidentType' => null
protected 'affectedPersons' =>
object(Doctrine\Common\Collections\ArrayCollection)[468]
private '_elements' =>
array (size=1)
0 =>
object(Krankikom\Entity\Person)[600]
...
protected 'reportingPerson' =>
object(Krankikom\Entity\Person)[504]
protected 'id' => null
protected 'incident' => null
protected 'title' => string '' (length=0)
protected 'firstName' => string '44' (length=2)
protected 'surName' => string '44' (length=2)
protected 'dateOfBirth' =>
object(DateTime)[728]
public 'date' => string '2014-05-02 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Berlin' (length=13)
protected 'address' => string '44' (length=2)
protected 'damagedItems' => string '' (length=0)
protected 'takenItems' => string '' (length=0)
protected 'businessDisruption' => boolean true
protected 'crimeReferenceNumber' => string '' (length=0)
protected 'description' => string '123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123' (length=132)
protected 'attachedFiles' =>
array (size=3)
0 =>
array (size=0)
empty
1 =>
array (size=0)
empty
2 =>
array (size=0)
empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment