Hey @mabusdogma
Sorry for the wait!
Here’s the code rewritten to satisfy both those constraints:
import streamlit as st
state = st.session_state
if "dict_options" not in state:
state.dict_options = {}
if "submitted" not in state:
state.submitted = False
options = ["option1", "option2", "option3", "option4"]
col1, col2, col3 = st.columns(3)
with col1.form("my_form"):
new_country = st.text_input("New country")
submit_button = st.form_submit_button(
label="Add new country", on_click=lambda: state.update(submitted=True)
)
if state.submitted:
state.dict_options[new_country] = col2.multiselect(
f"Select the options you want for {new_country}",
options,
default=options[:2],
)
col2.write(state.dict_options)