How to change the shape field in Subscriber
-
I do.
FormType
where there is a field. When the field is created, the field must be mandatory, editing is not mandatory.Subscriber
this one.type
♪Field in
FormType
->add("logo", FileType::class, [ "label" => "Health Plans logo", "mapped" => true, "required" => true ])
♪
postSetData
I take the form.$form->get('config')->get('logo')
- That's it.FormType
TotalFormType
I can see. So I'm taking the field.How do I set up the field?
mapped
Object received valuefalse
?
-
- Disclosure:
required
It's just that HTML puts it in.required
and a couple of plugs. This option has nothing to do with validation. http://symfony.com/doc/current/reference/forms/types/form.html#required To solve your problem in her current state, you can use the transmitted option.
data
e.g.public function buildForm(FormBuilderInterface $builder, array $options) { /** @var MyEntity $data */ $data = $options['data']; // ... ->add( "logo", FileType::class, [ "label" => "Health Plans logo", "mapped" => true, // данных нет или у них отсутствует id (т.е. ещё не создана) "required" => $data === null || empty($data->getId()) ] )
- Disclosure: