reflex
reflex copied to clipboard
Change behavior of switch, checkbox
class FormSwitchState(rx.State):
form_data: dict = {}
def handle_submit(self, form_data: dict):
"""Handle the form submit."""
self.form_data = form_data
def switch_form_example():
return rx.card(
rx.vstack(
rx.heading("Example Form"),
rx.form.root(
rx.hstack(
rx.switch(name="switch"),
rx.button("Submit", type="submit"),
width="100%",
),
on_submit=FormSwitchState.handle_submit,
reset_on_submit=True,
),
rx.divider(),
rx.hstack(
rx.heading("Results:"),
rx.badge(
FormSwitchState.form_data.to_string()
),
),
align_items="left",
width="100%",
),
width="50%",
)
Odd behaviour in switch I would expect it {"switch":"off"} or false but its empty in a form
https://github.com/user-attachments/assets/aa5eb99a-cf02-4304-bbc8-262f03a23d80
I would say it should set the form to True/False not off empty
same behavior for checkbox
Hello @Alek99 . Is this issue free ?
is anyone still working on this issue?? can i try fixing it?