I’m in a situation that I’m using clear_on_submit=False. Because some of my form widgets are required. So I’m putting that option to false. But I want to reset the value of widgets to empty if the user give all correct values and then click submit. But somebody suggested me to use st.session_state for that. I’m confused with that. Could anyone please solve me problem??
Here is the code block
def create():
st.header('Fill the from!!')
with st.form('Student From',clear_on_submit=False):
roll_no=st.text_input('Enter your roll_no').lower()
name=st.text_input('Enter your name').lower()
branch=st.text_input('Enter your branch').lower()
location=st.text_input('Enter your loaction').lower()
phone_no=st.text_input('Enter your phone')
submitted=st.form_submit_button('Submit')
if submitted:
if not roll_no:
st.warning('Please fill the roll number field !!')
elif len(phone_no)!=10:
st.warning('Phone number length should be 10',icon='🚨')
else:
insert(roll_no,name,branch,location,phone_no)