Before with my Symfony project with the version 6.1, I could do it.
{{ form_start(form, {'attr': {'id': 'form-add-meeting'}}) }}
{{ form_widget(form) }}
<label for="">Date *</label>
<input class="form-control" type="text" id="datepicker" name="datepicker" />
<label class="time-selector mt-3" for="">Horaire *</label>
<input type="time" name="time" class="form-control time-selector" id="time-selector-input" />
{{ form_end(form) }}
Now when I try with the version 7.3 of Symfony, I get that error : "An exception has been thrown during the rendering of a template ("Warning: Array to string conversion") in form_div_layout.html.twig at line 374"
I searched everywhere on the web and I don't find any answer, any solution.
I tried to add field by field with form_row and it doesn't work. Form_label doesn't work too.
The only way I succeed to make it work is with form_widget for each field but it's less interesting for me because after I have to add the errors messages, the label inside the view manually.
Here is the FormType:
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('jump', JumpAutocompleteField::class)
->add('purchase_custom_link', TextType::class, [
'mapped' => false,
'required' => false,
'label' => 'N° Sport Découverte',
'attr' => [
'class' => 'form-control mb-3'
]
])
->add('purchase_item', OrderLinkAutocompleteField::class)
->add('client_lastname', TextType::class, [
'required' => false,
'label' => 'Nom',
'attr' => [
'class' => 'form-control mb-3',
'maxlength' => 60
]
])
->add('client_name', TextType::class, [
'required' => false,
'label' => 'Prénom',
'attr' => [
'class' => 'form-control mb-3',
'maxlength' => 60
]
])
->add('client_email', EmailType::class, [
'required' => false,
'label' => 'Adresse email',
'attr' => [
'class' => 'form-control mb-3',
'maxlength' => 120
]
])
->add('client_phone', TextType::class, [
'required' => false,
'label' => 'Numéro de téléphone',
'attr' => [
'class' => 'form-control mb-3',
'maxlength' => 10
]
])
->add('client_age', TextType::class, [
'required' => false,
'label' => 'Âge',
'attr' => [
'class' => 'form-control mb-3',
'maxlength' => 2
],
])
->add('client_height', TextType::class, [
'required' => false,
'label' => 'Taille (cm)',
'attr' => [
'class' => 'form-control mb-3',
'maxlength' => 3
]
])
->add('client_weight', TextType::class, [
'required' => false,
'label' => 'Poids (kg)',
'attr' => [
'class' => 'form-control mb-3',
'maxlength' => 3
]
])
;
}
form_widget(form)byform_rest(form). See form_rest(form_view, variables) @ Symfony documentation's How to Customize Form Rendering. TwigStan @ GitHub might be helpful in debugging your issue.