Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting id on rx.select in a form does not update the form data on form submission #4214

Open
ElijahAhianyo opened this issue Oct 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ElijahAhianyo
Copy link
Collaborator

import reflex as rx

class FormState(rx.State):
    form_data: dict = {}

    def handle_submit(self, form_data: dict):
        """Handle the form submit."""
        self.form_data = form_data

app = rx.App()

@rx.page()
def index():
    return rx.vstack(
        rx.form(
            rx.vstack(
                rx.select(
                    ["apple", "grape", "pear"],
                    id="select",
                ),
                rx.button("Submit", type="submit"),
            ),
            on_submit=FormState.handle_submit,
            reset_on_submit=True,
        ),
        rx.divider(),
        rx.heading("Results"),
        rx.text(FormState.form_data.to_string()),
    )

When a value is selected, the form data is not updated on submission.
a workaround is to use the name prop

Related radix issue: radix-ui/primitives#2590

@ElijahAhianyo ElijahAhianyo added the bug Something isn't working label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant