@@ -35,6 +35,7 @@ def _django_form(
3535 on_success : Callable [[FormEvent ], None ] | None ,
3636 on_error : Callable [[FormEvent ], None ] | None ,
3737 on_submit : Callable [[FormEvent ], None ] | None ,
38+ on_change : Callable [[FormEvent ], None ] | None ,
3839 form_template : str | None ,
3940 top_children : Sequence ,
4041 bottom_children : Sequence ,
@@ -78,6 +79,10 @@ def _django_form(
7879 if not success and on_error :
7980 on_error (form_event )
8081
82+ def _on_change (_event ):
83+ if on_change :
84+ on_change (FormEvent (form = initialized_form , data = submitted_data or {}))
85+
8186 def on_submit_callback (new_data : dict [str , Any ]):
8287 """Callback function provided directly to the client side listener. This is responsible for transmitting
8388 the submitted form data to the server for processing."""
@@ -91,7 +96,8 @@ def on_submit_callback(new_data: dict[str, Any]):
9196 set_submitted_data (new_data )
9297
9398 return html .form (
94- {"id" : f"reactpy-{ uuid } " , "onSubmit" : event (lambda _ : None , prevent_default = True )} | extra_props ,
99+ {"id" : f"reactpy-{ uuid } " , "onSubmit" : event (lambda _ : None , prevent_default = True ), "onChange" : _on_change }
100+ | extra_props ,
95101 DjangoForm ({"onSubmitCallback" : on_submit_callback , "formId" : f"reactpy-{ uuid } " }),
96102 * top_children ,
97103 utils .html_to_vdom (
0 commit comments