I try to have a required value depends on radio button
$builder
->add('radio',ChoiceType::class,[
'label' => 'My radio button',
'choices'=>[
'Yes'=>'Yes',
"No"=>"No"
],
"expanded"=>true,
"multiple"=>false,
'required' => true,
'placeholder' => false
])
->add('file input', FileInputType::class, [
'label' => 'put your file',
'mapped' => false,
'required' => true or false // depends on radio button
])
But i can't find how to do this, i'm a beginner in symfony. I use Symfony 5
Please if you have an idea i'm listening
You can use JavaScript to handle the change event on the radio buttons and set
required
attribute for the 'file input' field accordingly.