Input reactpy #1140
Input reactpy
#1140
-
Hello, I've been wondering if there's anyway to get input data from forms in reactpy |
Beta Was this translation helpful? Give feedback.
Answered by
Archmonger
Sep 11, 2023
Replies: 1 comment 1 reply
-
You can attach an 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 {
... ,
'target': {'boundingClientRect': {},
'elements': [{'boundingClientRect': {},
'tagName': 'INPUT',
'value': 'example 1'},
{'boundingClientRect': {},
'tagName': 'INPUT',
'value': 'example 2'},
{'boundingClientRect': {},
'tagName': 'BUTTON',
'value': ''}],
'tagName': 'FORM'},
... ,
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Archmonger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can attach an
on_submit
event handler event to anyhtml.form
to see the submission values.For example, with the following simple application...
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…