diff options
author | Matt Arnold | 2025-04-15 09:58:58 -0400 |
---|---|---|
committer | Matt Arnold | 2025-04-15 09:58:58 -0400 |
commit | e8880e73a23571acf47845b1e38292239c5d71b2 (patch) | |
tree | 0f12139f68f7dd99646d257bc3519744ba5b2f2e /forms.py | |
parent | dc557895b1bd517bbdc2821a79f2be12624010d6 (diff) |
finally got different profiles/faccets to work.
Unsure if it was just the typo in the template or we really needed backend changes but belt and suspenders logic applies
Diffstat (limited to 'forms.py')
-rw-r--r-- | forms.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/forms.py b/forms.py index be0171a..ba427cd 100644 --- a/forms.py +++ b/forms.py @@ -1,13 +1,28 @@ from flask_wtf import FlaskForm -from wtforms import StringField, TextAreaField, SubmitField, PasswordField, BooleanField +from wtforms import ( + StringField, + TextAreaField, + SubmitField, + PasswordField, + BooleanField, + SelectField, +) from wtforms.validators import DataRequired class PostForm(FlaskForm): title = StringField("Title", validators=[DataRequired()]) content = TextAreaField("Content", validators=[DataRequired()]) + faccets = SelectField("Faccet", coerce=int) submit = SubmitField("Toot!") + def __init__(self, *args, **kwargs): + super(PostForm, self).__init__(*args, **kwargs) + # Populate the select field with profile from the database + self.faccets.choices = [(0, "Please select a profile")] + [ + (u.id, u.name) for u in kwargs["faccets"] + ] + class LoginForm(FlaskForm): """Login Form""" |