default form entries

geo
Alice 7 years ago
parent 85d0dba0b4
commit e151495683

@ -2,18 +2,21 @@
{% block main %} {% block main %}
<div class="container"> <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 method="POST" action="{{ url_for('edit_stack_by_id', id=stack.id )}}">
{{ form.csrf_token }} {{ form.csrf_token }}
<br> <br> <br> <br>
<table> <div class="form-group">
<tr> {{ 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> <br>
<button type="submit" class="btn btn-primary">Update</button> <button type="submit" class="btn btn-primary">Update</button>
</form> </form>

@ -306,13 +306,16 @@ def remove_stack_by_id(id):
@app.route('/stacks/<int:id>/edit', methods=['POST', 'GET']) @app.route('/stacks/<int:id>/edit', methods=['POST', 'GET'])
def edit_stack_by_id(id): def edit_stack_by_id(id):
stack = Stack.query.filter_by(id=id).first() 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 request.method == 'POST':
if form.validate_on_submit(): if form.validate_on_submit():
stack_name = form.edit_stack_name.data stack_name = form.edit_stack_name.data
stack_description = form.edit_stack_description.data stack_description = form.edit_stack_description.data
stack.stack_name = stack_name
stack.stack_description = stack_description
db.session.commit() db.session.commit()
return redirect(url_for('show_stack_by_id', id=id)) return redirect(url_for('show_stack_by_id', id=id))
return render_template('edit_stack_detail.html', stack=stack, form=form) return render_template('edit_stack_detail.html', stack=stack, form=form)
## search ## search

Loading…
Cancel
Save