I'm trying to customize how my form is displayed by using a form_snippet as suggested in the docs. Here's what I've come up with so far:
{% for field in form %}
<tr>
<th><label for="{{ field.html_name }}">{{ field.label }}:</label></th>
<td>
{{ field }}
{% if field.help_text %}<br/><small class="help_text">{{ field.help_text }}</small>{% endif %}
{{ field.errors }}
</td>
</tr>
{% endfor %}
Of course, field.html_name
is not what I'm looking for. I need the id
of the input field. How can I get that?
Also, is there a way I can determine if the field is required, so that I can display an asterisk beside the label?