I have created a contact form with symfony 5.3 and I have been asked to delete the placeholder showing as a first option when you click the dropdown:
This is my Form Type code for the dropdown:
->add('department', ChoiceType::class, [
'placeholder' => 'contact_form.department.label',
'choices' => [
'Unsubscribe' => 'Unsubscribe',
'Sales' => 'Sales',
'Marketing' => 'Marketing',
'Customer Support' => 'Customer Support',
],
'required' => true,
'constraints' => [
new NotBlank([
'message' => 'contact_form.department.not_blank',
]),
],
])
And the part of the twig template:
<div class="col-md-6">
<div class="form-select-wrapper mb-4">
{{ form_widget(form.department, {'attr': {'class': 'form-select', 'id': 'form-select', 'required': true, 'onchange': 'showValidationMessage(this, "department-valid-feedback", "department-error")'}}) }}
<div id="department-error" style="color: red; font-size: 14px; margin-top: 5px;">
{{ form_errors(form.department)|trans|raw }}
</div>
<div class="valid-feedback" id="department-valid-feedback" style="display: none;">
{{ 'Looks good!'|trans|raw }}
</div>
</div>
</div>
I can’t find the solution in the symfony docs.
