Form submit button disable after submit, enable after processing done


I want to disable the form submit button after the button hit. And after processing the form submit request, I want to enable the form button again.

I have tried following snippet. But it does not work. Maybe form is not rerendered.

Steps to reproduce

Code snippet:

def handler():
  st.session_state.submitted = True

st.form_submit_button(..., disabled=st.session_state.submitted, on_click=handler)

# ... after some code, finishing the process

st.session_state.submitted = False

If applicable, please provide the steps we should take to reproduce the error or specified behavior.


Can you provide a more complete code snippet so we can reproduce this issue? The code snippet you shared isn’t runnable.