У меня есть форма, в которой я динамически заполняю значения с помощью метода .default.
Примерно так:
for i, item in enumerate(staff):
if item.id == "csrf_token" or item.id == "submitstaff":
continue
item.default = stafftable[0][i]
staff.process()
Я также использовал эту форму без этого процесса, и она работает. Однако, когда я использую его после выполнения этого процесса, он всегда принимает значения по умолчанию, не позволяя пользователю больше обновлять значения. Например, если я отобразлю форму agian и попытаюсь изменить значения поля, оно примет поле .default, установленное процессом, а не входом.
Форма:
class Staff(FlaskForm):
staffid = StringField(
validators=[DataRequired(message="Staff Id Field can not be left blank")]
)
Firstname = StringField(
validators=[DataRequired(message="Firstname Field can not be left blank")]
)
LastName = StringField(
validators=[DataRequired(message="LastName Field can not be left blank")]
)
ProjectRole = StringField(
validators=[DataRequired(message="ProjectRole Field can not be left blank")]
)
YearsOfExperience = FloatField(
validators=[
DataRequired(message="Years of experience Field can not be left blank")
]
)
Organisation = SelectField(
"Organisations",
choices=[
("1","1"),
("1","1"),
("1","1"),
],
)
OfficeLocation = StringField(
validators=[DataRequired(message="Office location Field can not be left blank")]
)
Discipline = SelectField(
"Discipline",
choices=[
("Geotechnics", "Geotechnics"),
("Civil", "Civl"),
("Digital", "Digital"),
("Project Management", "Project Management"),
],
)
KeyPersonName = SelectField(choices=[("No","No"),("Yes","Yes")])
BatchNo = StringField(
validators=[DataRequired(message="BatchNo Field can not be left blank")]
)
ProjectStatus = StringField(
validators=[DataRequired(message="ProjectStatus Field can not be left blank")]
)
Booking = StringField(
validators=[DataRequired(message="Booking Field can not be left blank")]
)
TasksEarlyDeliverables = TextAreaField(
validators=[
DataRequired(
message="Tasks and early deliverables Field can not be left blank"
)
]
)
requester = StringField()
package = StringField()
PercentoftimeS1 = FloatField()
HourlyRate = FloatField()
PercentoftimeS2 = FloatField()
submitstaff = SubmitField(label="Submit", validators=[DataRequired()])