我试图设置这些WTForm字段的名称,而不必更改变量本身的名称。任何帮助表示赞赏。
class AddProblemForm(Form):
problem_point_value_data = [[10, 20, 30], [40, 50, 60], [70, 80, 90, 100], [120, 140, 160, 180, 200]]
problemName = StringField('problemName',_name="problemName", validators=[validators.DataRequired(), validators.Length(min=2, max=64)])
problem_description = PageDownField('problemDescription', validators=[validators.DataRequired(), validators.Length(min=10, max=512)])
flag = StringField('flag', validators=[validators.DataRequired(), validators.Length(min=5, max=64)])
problem_difficulty = SelectField('problemDifficulty', choices=[(x, x) for x in range(4)], coerce=int)
problem_points = SelectField('problemPoints', choices=[(x, diff) for x,diff in zip(range(len(app.config['POINTS'])), app.config['POINTS'])], coerce=int)
problem_category = SelectField('problemCategory', choices=[(x, cat) for cat,x in zip(app.config['CATEGORIES'], range(len(app.config['CATEGORIES'])))], coerce=int)
problem_solution = TextAreaField('problemSolution', validators=[validators.DataRequired()])
答案 0 :(得分:0)
这里的问题(并且是双关语是绝对有意的!)是您已经使用problemName = StringField()
定义了一个字段。除了' problemName'之外,没有其他任何内容可以被称为。
文本标签与Moses评论的不同,您的HTML可以显示任何内容。