I'm working on a front-end form which has an UploadField. There is no underlying model as the form data and the uploaded files are sent out as an email with attachments - no need to store anything in the database.
What I'm finding though is that when the form is submitted, the files, although are uploaded to the specified upload folder, they are not listed in $data. Does anyone know if UploadField works without an underlying model?
The UploadField is set up as follows:
private function getUploadImagesFieldGroup() {
$imageUploadField = new UploadField('UploadedImages', 'Upload Images');
$imageUploadField->setCanAttachExisting(false);
$imageUploadField->setCanPreviewFolder(false);
$imageUploadField->relationAutoSetting = false;
$imageUploadField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif','tiff'));
$imageUploadField->setFolderName('images/tmp-upload-images');
$imageUploadField->setTemplateFileButtons('UploadField_FileButtons_ORS');
$fg = new FieldGroup(
$imageUploadField
);
$fg->addExtraClass('upload ss-upload ss-uploadfield'); // had to add these classes because UploadField is added to FieldGroup
$fg->setName('UploadImagesFieldGroup');
return $fg;
}
In my form submission handler:
public function formSubmissionHandler($data, $form) {
// DEBUG
var_dump($data['UploadedImages'];
exit();
}
The output of the form submission:
array (size=6)
'Files' =>
array (size=1)
0 => string '49' (length=2)
'name' =>
array (size=1)
'Uploads' =>
array (size=1)
0 => string '' (length=0)
'type' =>
array (size=1)
'Uploads' =>
array (size=1)
0 => string '' (length=0)
'tmp_name' =>
array (size=1)
'Uploads' =>
array (size=1)
0 => string '' (length=0)
'error' =>
array (size=1)
'Uploads' =>
array (size=1)
0 => int 4
'size' =>
array (size=1)
'Uploads' =>
array (size=1)
0 => int 0
Any idea why this could be happening? Any suggestions or workarounds?
Thanks.
VWD.