Skip to content

Commit cc4fd22

Browse files
committed
Prep work for DB backed form
1 parent 8e2913f commit cc4fd22

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/reactpy_django/forms/transforms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Callable
3+
from typing import TYPE_CHECKING
44

55
from reactpy.core.events import EventHandler, to_event_handler_function
66

@@ -70,7 +70,7 @@ def ensure_input_elements_are_controlled(vdom_tree: VdomDict) -> VdomDict:
7070
return vdom_tree
7171

7272
vdom_tree.setdefault("eventHandlers", {})
73-
if vdom_tree["tagName"] in {"input"} and "onChange" not in vdom_tree["eventHandlers"]:
73+
if vdom_tree["tagName"] == "input" and "onChange" not in vdom_tree["eventHandlers"]:
7474
vdom_tree["eventHandlers"]["onChange"] = EventHandler(to_event_handler_function(_do_nothing_event))
7575

7676
if "children" in vdom_tree:

tests/test_app/forms/forms.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from django import forms
2+
from django.forms import ModelForm
3+
4+
from .. import models
25

36

47
class BasicForm(forms.Form):
@@ -43,3 +46,14 @@ class BasicForm(forms.Form):
4346
label="model multiple choice field", initial="1", queryset=models.TodoItem.objects.all()
4447
)
4548

49+
# Currently unsupported fields
50+
# multi_value_field = MultiValueField(label="multi value", initial="[email protected]")
51+
# split_datetime_field = forms.SplitDateTimeField(label="split datetime")
52+
# file_field = forms.FileField(label="file")
53+
# image_field = forms.ImageField(label="image")
54+
55+
56+
class DatabaseBackedForm(ModelForm):
57+
class Meta:
58+
model = models.TodoItem
59+
fields = "__all__"

0 commit comments

Comments
 (0)