Hi all,
Iβm having issues getting forms to work with a callback.
The code below has two input text widgets. When I click the button the code is supposed to display the values of the input text.
When I click the button once then the form clears and the default value (ββ) is displayed (I have checked this with A==ββ and returned True).
When I click the button a second time then the original values apprear.
This behaviour continues if I change the values and click the button, the new values are not displayed, but the most recent text -1 is returned.
def test_form():
def sub_function(A,B):
A
B
with st.form("my_test_form_0", clear_on_submit = True):
textA = st.text_input('Enter text A:', value = "",placeholder = 'enter here')
textB = st.text_input('Enter text B:', value = "",placeholder = 'enter here')
st.form_submit_button("Submit here!", on_click=sub_function, args=(textA,textB))
def main():
test_form()
main()
The values textA and textB are not bound until after the callback executes. Give the text_input widgets unique keys and access their values in the callback using those keys.