Answer the question
In order to leave comments, you need to log in
How to implement custom field validation with mapped false in symfony2?
Symfony version 2.7 In my form class inherited from AbstractFormType, a
field is added
in the buildForm(FormBuilderInterface $builder, array $options) method
$builder->add('passport_media', new OrderPassportMediaType(), [
'label' => 'Скан паспорта', 'mapped' => false, 'required' => true, 'property_path' => null
]);
$builder->addEventListener(FormEvents::POST_SUBMIT, array($this, 'orderListener'));
Answer the question
In order to leave comments, you need to log in
Lots of options...
1. mapped true (Just adding a field to the entity)
2. Listener (PRE_SUBMIT and other events)
3. As Aleksey Romanenko
suggested
4. ...
In general, file uploads should not intersect with the entity. That is, the entity and the loading process must exist separately. This will make it easier to both work with the entity and work with the file. (But these are the details)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question