-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Describe the bug
When set disabled attribute of a rx.input to a State variable, frontend form validation won't work.
To Reproduce
First, define a bool variable in a State.
class DebugState(rx.State):
debug_mode: rx.Field[bool] = rx.field(default=False)Then, set disabled to that state variable.
# ...
rx.form.root(
rx.form.field(
rx.form.label("Email"),
rx.form.control(
rx.input(
placeholder="Email Address",
disabled=DebugState.debug_mode,
type="email",
),
as_child=True,
),
rx.form.message(
"Please enter a valid email",
match="typeMismatch",
),
name="email",
),
rx.form.submit(
rx.button("Submit"),
as_child=True,
),
on_submit=lambda form_data: rx.window_alert(form_data.to_string()),
)
#...After set disabled to a state variable, frontend validation won't work anymore
If we try to remove disabled attribute or just set disabled attribute to constant value like False, frontend validation will work.
Expected behavior
When disabled attribute of a rx.input been set to a state variable, frontend validation should also work.
Screenshots
If applicable, add screenshots to help explain your problem.
Specifics (please complete the following information):
- Python Version: 3.12
- Reflex Version: 0.8.21
- OS: MacOS 26.1
- Browser (Optional): Google Chrome 142
Additional context
N/A
Metadata
Metadata
Assignees
Labels
No labels