python - Populate iterated form fields with data -


i cannot iterated form fields populate corresponding data.

it works fine when iterated regular object (appearing in template {{ h.name }} example), know data there - it's failing input when use value = argument within form.

i'm not sure if there's flaw in logic or approach displaying hourly entries, or syntax error.

here jinja template:

<tr>     <th>employee</th>     <th>date</th>     <th>regular hours</th>     <th>overtime hours</th>     {% if g.current_user.role == "administrator" %}     <th>rate</th>     {% endif %}     <th>edit</th>     {% h in workorder.work_order_hours %}     <tr>         <td>{{ form2.employee_name(value=h.name) }}</td>         <td>{{ form2.date(value=h.date) }}</td>         <td>{{ form2.regular_hours(value=h.regular_hours) }}</td>         <td>{{ form2.ot_hours(value=h.overtime_hours) }}</td>         <td>{{ form2.rate(value=h.rate) }}</td>     </tr>     {% endfor %} </tr> </table> 

here view:

@app.route('/workorders/<id>') @login_required def workorder_profile(id):     form = editworkorderform()     form2 = xeditableform()     form.customer.choices = [(cus.id, cus.company_name) cus in company.query.order_by('id')]     form2.employee_name.choices = [(e.id, e.first_name) e in users.query.order_by('id')]     workorder = workorder.query.filter_by(id = id).first_or_404()     form.work_notes.data = workorder.work_notes     form.status.data = workorder.status     form.customer.data = workorder.customer     return render_template('workorder_profile.html', workorder = workorder, form = form, form2 = form2) 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -