Please help, nested button are not working

edit_confirmed = edit_col2.button(“Edit the entry”)
if edit_confirmed:
with st.form(key=‘new-entry’):
##all the necessary edits

                #submit button and insert query
                submit_button = st.form_submit_button("Insert the Entry")
                
                #Insert statement
                if submit_button:
                    try:
                        update_entry_statement = f"UPDATE {table_name} SET TITLE = '{edited_title}'' WHERE CODE = '{choosed_code}'"
                        session.sql(update_entry_statement)
                        st.success("Entry Edited successfully")
                    except Exception as e:
                        st.error(f"Error updating entry: {e}")

I am trying for this code, as for editing part I am trying to add two buttons,
one which allows to opens the form after clicking (edit form button) and after filling out form (submit button) but the changes don’t reflects in table and it returns nothing. The form closes on it own. Please help me!!

Hi @Atharva_Deshpande . May be the following code block help you.

bt1=st.button('Submit')
if st.session_state.get('button') != True:
   st.session_state['button'] = bt1
if st.session_state['button'] == True:
    if st.button('Download'):
       st.session_state['button'] = False

The above code block works if the first button is clicked and set that button session state to false and then inside button will work smoothly without refreshing the page.

Happy Streamlit-ing :balloon:

thank you so much :smile:, I’ll try it