Answer the question
In order to leave comments, you need to log in
How to disable form submission when select is empty?
The question is probably stupid, please do not kick much, I'm just learning. Tell me, please, there is a registration form where you need to select the name of the organization in the select field, where a bunch of different options are offered. I need the select field to be empty by default when hitting the form, and so that the form submission is not possible.
The first part of the task is implemented, the select field is empty by default, but the form is still sent with an empty name of the organization.
I have the following twig file with the following piece of code:
<label>{{ _('Организация') }}*</label>
<select class="{% if widget.organization_error %} is-invalid-input{% endif %}" required name="organization">
{% for b in ncd_config.getBanksNames() %}
<option hidden selected></option>
<option value="{{b.name}}">{{b.name}}</option>
{% endfor %}
</select>
{% if widget.organization_error %}<span class="form-error is-visible">{{ widget.organization_error }}</span>{% endif %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question