Adding SelectQueryField Id attribute in Jinja2

Viewed 346

I'm trying to assign Id attribute to the SelectQueryField in Jinja. The problem is Jinja don't render variable in double curly brackets.

<form method="post" class="form form-inline" >
{{ form.opcje(class="form-control form-select", id="{{user.id}}" ) }}
</form>           

output:

<select class="form-control form-select" id="{{user.id}}" name="opcje"><option selected="" value="__None">Wybierz cechÄ™</option><option value="1">Sklepy</option><option value="2">Niemcy</option><option value="3">Holandia</option></select>
1 Answers

Try:

<form method="post" class="form form-inline" >
{{ form.opcje(class="form-control form-select", id=user.id ) }}
</form>  

You can use variables inside the first set of {{...}} freely.

Related