Comments (14)
Thanks :)
I've made this for workaround.
https://gist.github.com/genki/632d57ffc53a136521f486867756469b
from modular-forms.
Ok, feel free to create a PR for a submit
method. Contact me on GitHub or Discord if you have any questions. Currently I prefer to use .requestSubmit()
, but I am open to other options.
from modular-forms.
Did you check if the reload can be prevented by an argument or event.preventDefault()
?
from modular-forms.
Sorry for less information.
I made a runnable example here
https://stackblitz.com/edit/modular-forms-qwik-p4noyg?file=src%2Froutes%2Flogin%2Findex.tsx
- Fill the form and click submit button then the dialog will appear.
- Focus on the textarea and hit the Command+Enter or Ctrl+Enter then the page will reload.
I would like to simulate the first behaviour for the second case. Is there a way to do that?
from modular-forms.
I don't know. Probably I would not use the "submit" function of the <form />
element and call a function directly instead.
from modular-forms.
I see. If I call the function directly, how can I validate the form?
from modular-forms.
For example, this comment form here is possible to submit by hitting Command+Enter with validation.
I would like to have this function for the modular-forms.
from modular-forms.
You can call validate
: https://modularforms.dev/qwik/api/validate
from modular-forms.
I see, I will use it. Thank you :)
from modular-forms.
@fabian-hiller I have tried to call the validate()
but found an issue that the setFieldErrors()
and setErrorResponse()
are not exported so that we can't set the issues to the form.
How about to make the submit(formStore)
method in order to simulate the equivalent action of the manual form submit.
from modular-forms.
Oh, yes that's right. I will think about it. Until then, I recommend using validate
with setResponse
.
from modular-forms.
I tried to simplify the workaround a bit 😅, here is mine:
// Old-school solution:
// "cancelable" has to be true. It allows modular-forms to preventDefault that "submit".
form.element.dispatchEvent(new Event('submit', { cancelable: true, bubbles:true }));
// Or for modern browsers
form.element.requestSubmit();
@fabian-hiller Let me know if you are interested in a PR for a submit
helper with one/both of these patterns.
Related discussion:
final-form/react-final-form#878 (comment)
requestSubmit
Browsersupport: https://caniuse.com/mdn-api_htmlformelement_requestsubmit
from modular-forms.
form.element.requestSubmit();
Does this work without specifying a submitter as the first argument?
from modular-forms.
Yupp, in that case the form element itself is used as submitter :).
from modular-forms.
Related Issues (20)
- Qwik: Latest qwik release breaks types HOT 14
- Enhance FieldStore to Return Multiple Errors per Field HOT 2
- Phone Number Input HOT 1
- Allow setting initial form values of a mounted component HOT 2
- Preact: What is the best method to pull values of fields in the form for using in computed() HOT 4
- [Question] Is it possible to have optional fields? HOT 7
- Import error in formAction for qwik HOT 1
- Checkbox works improperly when use modular forms with kobalte HOT 7
- [Question] Is it possible to have custom input without ref? HOT 5
- When useFormStore is in a seperate file, it fails HOT 1
- Select component with number types HOT 3
- Using modular form Fields inside solidjs Dynamic component HOT 1
- Qwik: Vite is trying to externalize packages used in formAction$ HOT 3
- `requestSubmit` is not a function on Safari < 16 HOT 3
- Does this library support React Native? HOT 1
- Internal issue: Cannot read properties of null (reading 'internal') HOT 4
- SolidJS: Form reset action doesn't preventDefault like submit does. HOT 1
- [Qwik] Form state is reset after action returns an error HOT 1
- [React]: Preact Signals Dependency Update HOT 11
- [SolidJS]: How to handle errors from server? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modular-forms.