Clear forms on submit
Volker-H opened this issue · comments
Hi,
first of all - the library is really great.
Many thanks for making authentication that much easier!
One thing that I couldnt figure out yet is how to clear the forms after the User submits.
e.g. the update_user_detail or the reset_password --> the Information entered by the User remains after submitting.
Is there a parameter to add?
Best
Volker
Hi @Volker-H thank you for reaching out. You can try using st.experimental_rerun()
to clear to fields. Let me know if it helps.
Thank you for your quick reply!
Hmm is this the right place? Also tried it in the update function - but it´s not working.
if st.session_state["authentication_status"]:
try:
if authenticator.update_user_details(st.session_state["username"]):
st.success('Änderungen aktualisiert')
update_ufile()
st.experimental_rerun()
except Exception as e:
st.error(e)
I also tried st.rerun() - no success.
I'm surprised that not more people have this problem.
I will need to see if I can implement this somehow in the logic of the package itself. Stay tuned!
one addition, if I build forms myself I simply use:
with st.form('get_data', clear_on_submit=True):
After hitting the submit button the form is cleared.
Excellent, will add this to a future release!
I have a branch, that supports form key definitions and clear_on_submit parameter. But this is only for forgot password. Will update to other methods if I have time.
Usage examples
--------------
>>> authenticator.forgot_password()
>>> authenticator.forgot_password('formkey')
>>> authenticator.forgot_password('formkey', location='sidebar')
>>> authenticator.forgot_password('myformkey', location='main', fields={'Form name': 'Forgot password with key'})
>>> authenticator.forgot_password('formkey', clear_on_submit=True, location='main', fields={'Form name': 'Forgot password'})
Dear all the argument to clear forms has been added to all the widgets in the latest release v0.3.2.