From e151495683e85ee7b82787ec0107c09c6c326cce Mon Sep 17 00:00:00 2001 From: Alice Date: Wed, 6 Jun 2018 13:27:01 +0200 Subject: [PATCH] default form entries --- app/templates/edit_stack_detail.html | 19 +++++++++++-------- app/views.py | 5 ++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/templates/edit_stack_detail.html b/app/templates/edit_stack_detail.html index 8dd6ea8..6390e23 100644 --- a/app/templates/edit_stack_detail.html +++ b/app/templates/edit_stack_detail.html @@ -2,18 +2,21 @@ {% block main %}
- - {% from "_formhelpers.html" import render_field %} - + +
{{ form.csrf_token }}

- - +
+ {{ form.edit_stack_name.label }} {{ form.edit_stack_name(size=20, class="form-control") }} +

+
+ {{ form.edit_stack_description.label }} {{ form.edit_stack_description(size=20, class="form-control") }} +
- {{ render_field(form.edit_stack_name)}} - {{ render_field(form.edit_stack_description)}} -
diff --git a/app/views.py b/app/views.py index 788d76e..ccedbb1 100755 --- a/app/views.py +++ b/app/views.py @@ -306,13 +306,16 @@ def remove_stack_by_id(id): @app.route('/stacks//edit', methods=['POST', 'GET']) def edit_stack_by_id(id): stack = Stack.query.filter_by(id=id).first() - form = EditStackForm() + form = EditStackForm(edit_stack_name = stack.stack_name, edit_stack_description = stack.stack_description) if request.method == 'POST': if form.validate_on_submit(): stack_name = form.edit_stack_name.data stack_description = form.edit_stack_description.data + stack.stack_name = stack_name + stack.stack_description = stack_description db.session.commit() + return redirect(url_for('show_stack_by_id', id=id)) return render_template('edit_stack_detail.html', stack=stack, form=form) ## search