Bonjour,
Voici mon formulaire et bizarrement tous les champs sont à remplir obligatoirement. Comment rendre certains champs non-obligatoires ?
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('numfacture', TextType::class, ['required' => true])
->add('numtva', TextType::class, ['required' => true])
->add('datefacture', DateType::class, ['required' => true])
->add('vosinfos', TextareaType::class, ['required' => true])
->add('infosclient', TextareaType::class, ['required' => true])
->add('conditions', TextareaType::class, ['required' => true])
->add('consignes', TextareaType::class)
->add('designation1', TextareaType::class, ['required' => true])
->add('quantite1', IntegerType::class, ['required' => true])
->add('prixht1', NumberType::class, ['required' => true])
->add('taxe1', NumberType::class, ['required' => true])
->add('designation2', TextareaType::class)
->add('quantite2', IntegerType::class)
->add('prixht2', NumberType::class)
->add('taxe2', NumberType::class)
->add('designation3', TextareaType::class)
->add('quantite3', IntegerType::class)
->add('prixht3', NumberType::class)
->add('taxe3', NumberType::class)
;
}
Voici les champs que je veux pas rendre obligatoires :
->add('designation2', TextareaType::class)
->add('quantite2', IntegerType::class)
->add('prixht2', NumberType::class)
->add('taxe2', NumberType::class)
->add('designation3', TextareaType::class)
->add('quantite3', IntegerType::class)
->add('prixht3', NumberType::class)
->add('taxe3', NumberType::class)
Merci
Merci ça marche et il fallait que je mette aussi nullable=true
sur les propriétés non-requis de l'entité. Merci