I need generate select. If type=1 my select must be optgroup, if type=2 not. For example:
<select>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
and I have variable and table (for example of course):
{% set type = 1 %}
{% set cars = ['Swedish Cars': ['1': 'Volvo', '2': 'Saab'], 'German Cars': ['1': 'Mercedes', '2': 'Audi']] %}
<select>
{% if type==1 %}
{% for key, val in cars %}
<optgroup label="{{ key }}">
{% for key2, val2 in val %}
<option value="{{ key2 }}">{{ val2 }}</option>
{% endfor %}
</optgroup>
{% endfor %}
{% elseif type==2 %}
{% for key, val in cars %}
{% for key2, val2 in val %}
<option value="{{ key2 }}">{{ val2 }}</option>
{% endfor %}
{% endfor %}
{% endif %}
</select>
I can fix it, ex:
<select>
{% if type==1 %}
{% for key, val in cars %}
<optgroup label="{{ key }}">
{% for key2, val2 in val %}
<option value="{{ key2 }}">{{ val2 }}</option>
{% endfor %}
</optgroup>
{% endfor %}
{% endif %}
{% if type==2 %}
{% for key, val in cars %}
{% for key2, val2 in val %}
<option value="{{ key2 }}">{{ val2 }}</option>
{% endfor %}
{% endfor %}
{% endif %}
</select>
but what is wrong with elseif?