有关HTML中按钮的注意事项,关键是只有被按下的按钮才能将其数据发送回服务器。因此,您只需检查按钮
data字段是否已使用
ifform.process_button.data事物设置即可,在一般情况下即可使用。
在您的特定情况下,由于两个按钮都从相同的基础参数名称(
action)中提取数据,因此您需要检查按钮字段之一中的数据是否符合您的期望:
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



