form: generate a unique on_submit suffix in create (#2154)

This commit is contained in:
Masen Furer 2023-11-13 12:52:26 -08:00 committed by GitHub
parent ea22452b27
commit 27b09132b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,22 @@ class Form(ChakraComponent):
reset_on_submit: Var[bool] = False # type: ignore
# The name used to make this form's submit handler function unique
handle_submit_unique_name: Var[str] = get_unique_variable_name() # type: ignore
handle_submit_unique_name: Var[str]
@classmethod
def create(cls, *children, **props) -> Component:
"""Create a form component.
Args:
*children: The children of the form.
**props: The properties of the form.
Returns:
The form component.
"""
if "handle_submit_unique_name" not in props:
props["handle_submit_unique_name"] = get_unique_variable_name()
return super().create(*children, **props)
def _get_imports(self) -> imports.ImportDict:
return imports.merge_imports(