Data Editor in form not updating the edited dataframe when submit button is clicked

I have managed to suss this by doing this:

if 'dek' not in st.session_state:
    st.session_state.dek = str(uuid.uuid4())

....

# add key=st.session_state.dek to st.editor statement
....

form_02()

if 'form_data' in st.session_state:
    if len(st.session_state.form_data):
        json_data = json.dumps(st.session_state.form_data.to_json(orient="records"))
        json_data
        st.session_state.dek = str(uuid.uuid4())

Now if I press the submit button and dataframe is empty in the form it all works as expected. This post helped: