Skip to content

Input reactpy #1140

Answered by Archmonger
yickysan asked this question in Question
Sep 10, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can attach an on_submit event handler event to any html.form to see the submission values.

For example, with the following simple application...

from pprint import pprint

from reactpy import component, event, html, run


@component
def example():
    
    @event(prevent_default=True)
    def on_submit(event):
        pprint(event)

    return html.form(
        {"on_submit": on_submit},
        html.input({"type": "text"}),
        html.input({"type": "text"}),
        html.button({"type": "submit"}, "Submit"),
    )


run(example)

You can see the contents of the form submission via the event["target"]["elements"]. The form elements are returned in the same order they were rendered i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yickysan
Comment options

Answer selected by Archmonger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants