Checkbox in FileType have required true as default
Asyjjan opened this issue · comments
Hi, when trying to upload a file I noticed that if we render the form with a FileType in, we can't submit until we checked the delete checkbox button so we can't submit
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('file', FileType::class, [
'label' => false,
'file_path' => 'image', // Required, see Options
'allow_delete' => true,
'file_label' => 'Fichier',
])
->add('submit', SubmitType::class, [
'label' => 'Envoyer'
])
;
}
{% block body %}
{{ form(form) }}
{% endblock %}
We get a checkbox like this :
<input type="checkbox" id="image_form_file_delete" name="image_form[file][delete]" required="required" class="form-check-input" value="1">
Fixed by using Leapt's form theme.