This does not hide the month and day widgets entirely…
{% block date_widget %}
{% spaceless %}
{% if widget == 'single_text' %}
{{ block('field_widget') }}
{% else %}
<div {{ block('widget_container_attributes') }}>
{{ date_pattern|replace({
'{{ year }}': form_widget(form.year),
'{{ month }}': form_widget(form.month, { 'attr' : { 'style': 'display:none' }}),
'{{ day }}': form_widget(form.day, { 'attr' : { 'style': 'display:none' }}),
})|raw }}
</div>
{% endif %}
{% endspaceless %}
{% endblock date_widget %}
…and this:
'{{ month }}': '',
'{{ day }}': '',
fails during validation.
Any ideas how we can remove day and month widgets from the date form field?
The
datetype without themonthanddayparts is just ayeartype. So, why don’t you create one instead of misusing the type meant for dates?You could use the
choicetype or create ayeartype based on it. You could also take a look at theyearsoptions of thebirthdaytype and add a similar option to your new type.