created generic id_name_form.html and made condition, covertype, genre, owned, publisher & rating use it for single edit page
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from wtforms import SubmitField, StringField, HiddenField, validators, Form
|
||||
from flask_wtf import FlaskForm
|
||||
from flask import request, render_template
|
||||
from __main__ import db, app, ma
|
||||
|
||||
@@ -24,7 +25,7 @@ class AuthorSchema(ma.SQLAlchemyAutoSchema):
|
||||
################################################################################
|
||||
# Helper class that defines a form for author, used to make html <form>, with field validation (via wtforms)
|
||||
################################################################################
|
||||
class AuthorForm(Form):
|
||||
class AuthorForm(FlaskForm):
|
||||
id = HiddenField()
|
||||
firstnames = StringField('FirstName(s):', [validators.DataRequired()])
|
||||
surname = StringField('Surname:', [validators.DataRequired()])
|
||||
@@ -49,7 +50,8 @@ def author(id):
|
||||
### DDP: should this be request.form or request.values?
|
||||
alert="Success"
|
||||
author_form = AuthorForm(request.form)
|
||||
if request.method == 'POST' and author_form.validate():
|
||||
print( author_form.validate_on_submit() )
|
||||
if request.method == 'POST' and author_form.validate_on_submit():
|
||||
id = request.form['id']
|
||||
author = Author.query.get(id)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user