fix: empty html options need to have a label (#18503)

* fix: empty html options need to have a label

empty options are errors in html validators and they need
to have at least a label to be correct. By adding a label
we solve the problem with the validator while keeping the
code functionallity the same. Related to #12747

Signed-off-by: Thanasis Mpalatsoukas <thanasismpalatsoukas@gmail.com>

* Update templates/config/form_display/input.twig

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>

---------

Signed-off-by: Thanasis Mpalatsoukas <thanasismpalatsoukas@gmail.com>
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Co-authored-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Sakis bal 2023-06-17 20:37:50 +03:00 committed by GitHub
parent af6f448842
commit be3223ad1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,7 @@
<select name="{{ path }}" id="{{ path }}" class="w-75{{ not value_is_default ? (has_errors ? ' custom field-error' : ' custom') }}">
{% for key, val in select_values %}
{% if val is same as(true) %}{% set val = 'Yes'|trans %}{% elseif val is same as(false) %}{% set val = 'No'|trans %}{% endif %}
<option value="{{ key }}"{{ key is same as(value) or (value is same as(true) and key is same as(1)) or (value is same as(false) and key is same as(0)) ? ' selected' }}{{ key in select_values_disabled ? ' disabled' }}>{{ val }}</option>
<option value="{{ key }}"{{ val is empty ? ' label="' ~ 'None'|trans ~ '"'}}{{ key is same as(value) or (value is same as(true) and key is same as(1)) or (value is same as(false) and key is same as(0)) ? ' selected' }}{{ key in select_values_disabled ? ' disabled' }}>{{ val }}</option>
{% endfor %}
</select>
{% elseif type == 'list' %}