On my form, I have two buttons that I use for submitting the form. One button deletes selected files (presented in a table, one checkbox to an object) and the other selects
The key thing to note about buttons in HTML is that only the button that was pressed sends its data back to the server. So you can just check if the button's data
field is set using if form.process_button.data
an things will work in the general case.
In your particular case, since both of your buttons pull their data from the same underlying parameter name (action
) you will need to check that the data in one of your button fields is what you would expect:
def validate_files(form, field):
# If the ButtonFields used different names then this would just be
# if form.process_button.data:
if form.process_button.data == ProcessForm.PROCESS:
# Then the user clicked process_button
else:
# The user clicked delete_button