streamlit-pydantic icon indicating copy to clipboard operation
streamlit-pydantic copied to clipboard

Optional field are set to value if input is not passed in json output

Open tommasogallingani opened this issue 1 year ago • 0 comments

Optional field are set to value if input is not passed in json output.

Describe the bug:

This output of this code if opt_int is not set is the one reported in the picture

class ModelTest(BaseModel):
    name: str = Field(title='Name')
    opt_int: Optional[int] = Field(title='Optional int')

data = sp.pydantic_form(model=ModelTest, key="Data entry", group_optional_fields='expander')
st.text(data)

image

while the Expected behaviour: is a json containing only the user input {name='a'}

tommasogallingani avatar Nov 02 '23 09:11 tommasogallingani