I have a form class that I set defaults (the users current information) so that it would pre-populate the form. However, this is causing validation issues as in the case of Required() it is accepting the default as the input. However, InputRequired() seems to fix that issue but it is not validating Email() correctly. It seems to accept any input...
How do I pre-populate the form with the users current data but only submit the current values to validation?
#My Form Class
class UserInfoForm(Form):
id = HiddenField('Employee ID')
fullName = TextField('Full Name', validators=[InputRequired()])
position = SelectField('Employee Position', coerce=int)
email = TextField('Email Address', validators=[InputRequired(), Email()])
password = PasswordField(
'New Password',
validators=[EqualTo('confirm', message='Passwords must match.')])
confirm = PasswordField('Repeat Password')
#My View
form = UserInfoForm()
form.position.choices = [(p.id, p.title) for p in EmpPosition.query.order_by('id')]
form.position.default = current_user.position.id
form.fullName.default = current_user.fullName
form.email.default = current_user.email
form.process()
if form.validate_on_submit():
#Submit to DB
return render_template('profile.html', data=data, form=form)
DataRequired()?