I am trying to a assign a value to a WTForm field within the HTML template. I need to do it this way as the value assigned will depend on what iteration of the for loop it is in. Any other way of passing a value back to the python script will work as well.
I am currently getting an error. I am trying to assign the record field of the form equal to the id of the record it is currently viewing.
Below is the code:
<div class="modal-body"> <p>Name of Training: {{ record.training_name }}</p> <p>Name of Provider: {{ record.training_provider }}</p> <p>Date of Training: {{ record.date_submitted.strftime('%d/%m/%Y') }}</p> <p>CPD Hours: {{ record.cpd }}</p> <p>Certificate: <a href="{{ url_for('static', filename='certificates/'+record.certificate_path) }}" target="_blank">View</a></p> <form action="" method="post"> {{ form.hidden_tag() }} <fieldset> <div class="form-group"> {{ form.reason(class="form-control", placeholder="Reason for Denial (if applicable)") }} {% set form.record.data=record.id %} </div> </fieldset> When attempting to use the solution above I am getting the following error: jinja2.exceptions.TemplateSyntaxError: expected token 'end of statement block', got '.'