Skip to content

What's the recommended way to use PyScript on form submit? #1146

Answered by lwcorp
lwcorp asked this question in Q&A
Discussion options

You must be logged in to vote

Nice! Can it be added to the FAQ and examples?

But first there is one issue - your example doesn't support initial values like <input id="email" value="initial value">, so here's my attempt to support it using form_values["email"]=Element("email").element.value which is of course annoying since it's manual and one might have lots of fields...

        <form id="form" py-submit="submit_handler()" reset="reset_handler()">
            <label for="email">Email:</label>
            <input 
            id="email" 
            name="email" 
            type="email" 
            placeholder="your.email@example.com"
            value="initial@value.com"
            py-input="email_input_handler()" …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

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

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