question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Form doesn't grab values after a submit

See original GitHub issue

I have a form that looks like such:

<Form
                onSubmit={approveAndList}
                buttonConfig={{
                    isLoading: false,
                    type: "submit",
                    theme: "primary",
                    text: "Sell NFT!",
                }}
                data={[
                    {
                        value: "",
                    },
                    {
                        value: "",
                    },
                    {
                        value: "",
                    },
                ]}
                title="Sell your NFT!"
                id="Main Form"
            />

And a approveAndList function that looks like such:

    async function approveAndList(data: any) {
        console.log(data.data[0].inputResult)
        console.log(data.data[1].inputResult)
        console.log(data.data[2].inputResult)
    }

In my UI, I have this for the form: Screen Shot 2022-04-23 at 3 28 41 PM

On the first submit, I’ll be able to console.log out the correct variables from the form.

Now, if I don’t touch the form, the UI will still have those values in their fields, but in the code they will show up as blank and I have to reenter them even though the UI shows the fields still populated.

Could we have these by default grab whenever value is in them? Or have them cleared anytime a form is submitted?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
PatrickAlphaCcommented, Apr 25, 2022

Glad to add helpful issues to keep improving this much needed project!!

1reaction
BillyG83commented, Apr 24, 2022

nice suggestion @rayyan224 TY

Ty for the report Patrick!

I was also going to add that on successful return of the data I had expected that you would perform some action that would remove the form and maybe render a nice message perhaps?

Either way you can track the pull request i just opened. It will disable the submit button after its clicked and the data is successfully returned. At least now you can’t get the empty data, which was buggy for sure. Also just FYI this is a minimal change because I plan to refactor Form soon and I don’t want to push too many breaking changes as traction on the kit is really heating up.

Thanks for using the kit and reporting the issue @PatrickAlphaC you are a valued member of the web3uiKit community 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot get POST value of submitted form - Stack Overflow
The problem is disabled fields are not submitted. <input type="text" name="recipientemail" value="email@email.com" disabled />.
Read more >
<input type="image"> - HTML: HyperText Markup Language
A string indicating the HTTP method to use when submitting the form's data; this value overrides any method attribute given on the owning...
Read more >
How to Prevent a Form from Clearing Fields on Submit
This video is a sample from Skillsoft's video course catalog. In JavaScript, you can use HTML forms for all sorts of purposes but...
Read more >
submit - Cypress Documentation
If the form being submitted includes inputs with client-side validation and that validation fails, .submit() will fail and list the validation failures. Rules....
Read more >
How to Get the Value of a Form Input on Submit in React
The button element in the form has a type of submit , so every time the user clicks it, the submit event is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found