我在网上找到的大多数信息都是针对多个复选框的。我只想要1.
我有:
define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);
我的'类别'模板:
class CategoryForm(FlaskForm):
category = StringField('category',validators=[DataRequired()])
checkbox = BooleanField('Private?')
@app.route('/category/<categoryid>',methods=('GET','POST'))
def category(categoryid):
category = Category.query.get(categoryid)
if request.method == 'POST':
if request.form.get('category'):
category.name = request.form['category']
category.private = request.form['private']
db.session.add(category)
db.session.commit()
return redirect(url_for('index'))
c_form = CategoryForm()
c_form.category.data = category.name
return render_template('category.html',form =c_form,category=category)
现在我的浏览器呈现:
<form method="post">
{{ form.hidden_tag() }}
{{ form.checkbox }}
<button type="submit">Go!</button>
</form>
显然我希望它能够呈现复选框。我怎样才能做到这一点?我需要一个小部件吗?