@@ -35,6 +35,7 @@ def _django_form(
35
35
on_success : Callable [[FormEvent ], None ] | None ,
36
36
on_error : Callable [[FormEvent ], None ] | None ,
37
37
on_submit : Callable [[FormEvent ], None ] | None ,
38
+ on_change : Callable [[FormEvent ], None ] | None ,
38
39
form_template : str | None ,
39
40
top_children : Sequence ,
40
41
bottom_children : Sequence ,
@@ -78,6 +79,10 @@ def _django_form(
78
79
if not success and on_error :
79
80
on_error (form_event )
80
81
82
+ def _on_change (_event ):
83
+ if on_change :
84
+ on_change (FormEvent (form = initialized_form , data = submitted_data or {}))
85
+
81
86
def on_submit_callback (new_data : dict [str , Any ]):
82
87
"""Callback function provided directly to the client side listener. This is responsible for transmitting
83
88
the submitted form data to the server for processing."""
@@ -91,7 +96,8 @@ def on_submit_callback(new_data: dict[str, Any]):
91
96
set_submitted_data (new_data )
92
97
93
98
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 ,
95
101
DjangoForm ({"onSubmitCallback" : on_submit_callback , "formId" : f"reactpy-{ uuid } " }),
96
102
* top_children ,
97
103
utils .html_to_vdom (
0 commit comments