FileType why you need a property data_class?

Kind time of day dear!

Study Symfony3, went through half a dozen options for creating/processing field to upload several files at once.

Among other things, when creating/adding a field of type FileType this field has the attribute data_class. Why such an attribute on the form itself - I understand, but why this attribute FileType not entirely clear to me.

VendorFile - this class I created, for test

Code example:
class VendorType extends AbstractType
{
/**
 * {@inheritdoc}
*/
 public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('www')
 ->add('file1', FileType::class, [
 'multiple' => 'multiple',
 'data_class' => VendorFile::class, //this line of code I have is neponyatki
])
 ->add('Ready', SubmitType::class);
 }


In any case, data_class, the purposes for which it can be applied? If not difficult, please give a simple example, how and when to use? Possible I would also like to hear some theory on this subject.

Also I do not understand why is not called a class constructor VendorFile? I imagined that the properties in this class must be initialize properties of the object UploadFile, but apparently it is not.
July 2nd 19 at 17:16
1 answer
July 2nd 19 at 17:18
->add('file1', FileType::class, [
 'multiple' => 'multiple', <-- This is a Boolean property and it will not work in this case
 'data_class' => VendorFile::class, //this line of code I have is neponyatki
])


data_class need for mapping data from a $_FILES to an object.

symfony.com/doc/current/reference/forms/types/file...
>> 'multiple' => 'multiple', <-- This Boolean property and it will not work in this case
don't know how, but it works, may be converted to True, but with Your comment I completely agree, this is a Boolean property

>> data_class need for mapping data from a $_FILES to an object.
prompt please, in what cases it may be useful/necessary and why is not called the constructor of this class? Is it possible in this class to set any handlers, for example, HasLifecycleCallback created specifically for this file? - Salvado commented on July 2nd 19 at 17:21
: Please refer to the example from the documentation symfony.com/doc/current/controller/upload_file.html assume that everything will fall into place. - Uriel_Tow commented on July 2nd 19 at 17:24
: read carefully, twice. Unfortunately, whether something I really don't know whether the link above is not disclosed the theme and there are no examples of the replacement of the standard File object in the data_class option on your. I.e. I understand it as you can/need to download the files, but did not understand in what cases you may need to override data_class for the file and why is not called a constructor. - Salvado commented on July 2nd 19 at 17:27

Find more questions by tags Symfony