Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
168a727
Client side form handler
Archmonger Dec 3, 2024
98ba450
misc changelog bump
Archmonger Dec 3, 2024
14c9dde
Functional client code
Archmonger Dec 5, 2024
ebd87bf
First draft of form conversion
Archmonger Dec 5, 2024
164e3a3
format
Archmonger Dec 5, 2024
cf08add
Move code to forms module
Archmonger Dec 5, 2024
f0702d0
Squash some bugs with multi choice and boolean fields
Archmonger Dec 6, 2024
63e23d5
Remove auto submit from the base form
Archmonger Dec 6, 2024
66fa334
Create form test
Archmonger Dec 6, 2024
3863eb2
Add bootstrap form
Archmonger Dec 6, 2024
4565df0
add events for form component
Archmonger Dec 6, 2024
24cc64b
Add on_change event
Archmonger Dec 6, 2024
edca217
simplify ensure_input_elements_are_controlled
Archmonger Dec 6, 2024
8e2913f
Support model choice fields
Archmonger Dec 6, 2024
cc4fd22
Prep work for DB backed form
Archmonger Dec 6, 2024
f0b21c7
Full support for database backed forms
Archmonger Dec 6, 2024
851b113
Fix render loop bug
Archmonger Dec 6, 2024
6bf8c24
quick self review
Archmonger Dec 6, 2024
4077a06
Add changelog
Archmonger Dec 6, 2024
08034fa
Simplify transforms
Archmonger Dec 7, 2024
24ad84c
Add extra transforms arg
Archmonger Dec 7, 2024
9360e51
REACTPY_DEFAULT_FORM_TEMPLATE
Archmonger Dec 7, 2024
7371a45
better input transform
Archmonger Dec 7, 2024
8c9990f
var name cleanup for _find_selected_options
Archmonger Dec 7, 2024
a54f035
cleanup in transform_value_prop_on_input_element
Archmonger Dec 7, 2024
78fdbed
simplify convert_multiple_choice_fields
Archmonger Dec 7, 2024
c8c71c4
Remove unsupported fields comment
Archmonger Dec 7, 2024
282e542
Rename cancel btn to reset
Archmonger Dec 7, 2024
bd58a1b
Move extra props arg
Archmonger Dec 7, 2024
d446161
Set default attributes in transforms
Archmonger Dec 7, 2024
aee08da
Fix edge case where error is thrown on empty choice field
Archmonger Dec 7, 2024
9c28f97
First cut at docs
Archmonger Dec 8, 2024
88ba295
Refactoring related to new docs
Archmonger Dec 8, 2024
a44591f
use local bootstrap for tests
Archmonger Dec 8, 2024
16c04bc
Remove default values from test form
Archmonger Dec 8, 2024
d561c88
self review
Archmonger Dec 8, 2024
d9416d9
Add tests
Archmonger Dec 9, 2024
208ec17
Add readme
Archmonger Dec 9, 2024
602be6b
Try dynamically selecting options for file_path_field
Archmonger Dec 9, 2024
1d3d095
Update todo comments
Archmonger Dec 9, 2024
b6fb5c4
Increase sleep on async relational query test
Archmonger Dec 9, 2024
608acee
Add another check in query tests
Archmonger Dec 9, 2024
3f834ca
Fix default on admin middleware
Archmonger Dec 9, 2024
73967b4
New ensure_async util function
Archmonger Dec 9, 2024
e32fc67
fix bad import
Archmonger Dec 9, 2024
3ed84db
Add thread_sensitive arg to ensure_async func
Archmonger Dec 10, 2024
55daaa2
Add new tests for form events
Archmonger Dec 10, 2024
5eb5818
run formatter
Archmonger Dec 10, 2024
998041a
another simplification of middleware
Archmonger Dec 10, 2024
78d5f38
Fix bug where input elements were dismounted prematurely
Archmonger Dec 11, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prep work for DB backed form
  • Loading branch information
Archmonger committed Dec 6, 2024
commit cc4fd2253bccde7797ff9bcc345a3690b5ba0de1
4 changes: 2 additions & 2 deletions src/reactpy_django/forms/transforms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Callable
from typing import TYPE_CHECKING

from reactpy.core.events import EventHandler, to_event_handler_function

Expand Down Expand Up @@ -70,7 +70,7 @@ def ensure_input_elements_are_controlled(vdom_tree: VdomDict) -> VdomDict:
return vdom_tree

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

if "children" in vdom_tree:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_app/forms/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from django import forms
from django.forms import ModelForm

from .. import models


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

# Currently unsupported fields
# multi_value_field = MultiValueField(label="multi value", initial="example@gmail.com")
# split_datetime_field = forms.SplitDateTimeField(label="split datetime")
# file_field = forms.FileField(label="file")
# image_field = forms.ImageField(label="image")


class DatabaseBackedForm(ModelForm):
class Meta:
model = models.TodoItem
fields = "__all__"