Here is my form type:
class TestFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$
I cannot exactly solve your problem, because in my opinion you're doing it the wrong way. A data class is actually only responsibly for keeping your data, so your method set/getThumbnailData
should look like this
thumbnailData = $thumbnailData;
}
public function getThumbnailData() {
return $this->thumbnailData;
}
In your controller you have something like this:
handleRequest($request);
if($form->isValid()) {
$test = $form->getData();
/* @var $test Test */
$thumbnailUploader = $this->get('thumbnail_uploader');
/* @var $thumbnailUploader ThumbnailUploadService */
$file = $test->getThumbnailData();
$filename = $file->getClientOriginalName();
$thumbnailUploader->upload($filename, $file);
// ...
}
}
I recommend to move all logic which has nothing to do with forms or requests into services. Your service in this case can be more generic handle any symfony files with a given filename.