default form entries

This commit is contained in:
Alice 2018-06-06 13:27:01 +02:00
parent 85d0dba0b4
commit e151495683
2 changed files with 15 additions and 9 deletions

View File

@ -2,18 +2,21 @@
{% block main %}
<div class="container">
{% from "_formhelpers.html" import render_field %}
<!--
{% from "_formhelpers.html" import render_field %} -->
<!--
{{ render_field(form.edit_stack_name)}}
{{ render_field(form.edit_stack_description)}} -->
<form method="POST" action="{{ url_for('edit_stack_by_id', id=stack.id )}}">
{{ form.csrf_token }}
<br> <br>
<table>
<tr>
<div class="form-group">
{{ form.edit_stack_name.label }} {{ form.edit_stack_name(size=20, class="form-control") }}
</div><br>
<div class="form-group">
{{ form.edit_stack_description.label }} {{ form.edit_stack_description(size=20, class="form-control") }}
</div>
{{ render_field(form.edit_stack_name)}}
{{ render_field(form.edit_stack_description)}}
</tr>
<br>
<button type="submit" class="btn btn-primary">Update</button>
</form>

View File

@ -306,13 +306,16 @@ def remove_stack_by_id(id):
@app.route('/stacks/<int:id>/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