I have the following PHP code that generates current year, and loops it until it reaches the 10th year.
<?php for ($i=date('Y'); $i <= date('Y', strtotime('+10 years')); $i++) : ?>
<option value="<?php echo $i; ?>"
<?php endfor; ?>
I an new on twig, and would like to ask for assistance on how to make it.
Here's a couple options using lists, can repurpose pretty easily for an option...
<ul>
{% for i in "now"|date("Y").."now +10 years"|date("Y") %}
<li>{{ ("now +"~(loop.index-1)~" years")|date("Y") }}</li>
{% endfor %}
</ul>
{% set minYear = "now"|date("Y") %}
{% set maxYear = "now +10 years"|date("Y") %}
<ul>
{% for year in minYear..maxYear %}
<li>{{ year }}</li>
{% set year = year + 1 %}
{% endfor %}
</ul>