I have a form that has a fieldset with a file upload field in it. When I do a var_dump on $form->getData() I am being shown an array of data for the file field:
array (size=13)
'logo' =>
array (size=5)
'name' => string 'my-image.gif' (length=12)
'type' => string 'image/gif' (length=9)
'tmp_name' => string 'C:\xampp\htdocs\images\my-image.gif' (length=35)
'error' => int 0
'size' => int 391
//... other fields here
How do get the element to return only the name when I call getData?
e.g.
array (size=13)
'logo' => string 'my-image.gif' (length=12)
//... other fields here
I am using the form for other things and have already overridden getData so would like to keep the answer located in the fieldset.
You can override the getData() method in your form.
Add all necessary precautions to ensure the existence of the keys in the arrays.
Supplements for a fieldset
Using a fileset, you can use a Filter to change the return file structure :
Your fieldset class must implement InputFilterProviderInterface
You can chain multiple filters, eg to rename the file before.