-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom inputs guide - how to emit events from the FormKit component? #140
Comments
I think I didn't properly explain in there, the tldr is here: https://formkit.link/b25b8b61ac56e13d8a61d73805c6835b But what I mean by So if you wanted to define an event you can just use attrs or props, any attrs will be in |
Ah, that makes sense! Thanks for the explanation again! |
Yeh I can see the confusion, as |
I understand, thanks for the clarification. we can simply define a function in We should definitely add this to the documentation, it will be helpful to others using FormKit. If it can help, I'll write a basic summary and code example from the info you gave, then do a pull request to the docs page. Also not sure if your codepen is referenced anywhere, but would also be good to have in the guides. Never contributed to open-source docs before, if there is a specific procedure lmk :) |
That would be awesome, there isn't and we will take a look in the PR if you make one, so no worries. |
Related discussion and solution by @SuddenDev: https://github.com/orgs/formkit/discussions/943#discussioncomment-9893014
In regards to emitting events from a custom FormKit input. I lost a lot of time today trying to figure this out, I could not find any related documentation to point me in the right direction.
All I found was a one-line note in the 'Architecture' documentation: https://formkit.com/essentials/architecture#emitting-events
Just adding a small paragraph with a code example in the custom input guide (https://formkit.com/guides/create-a-custom-input) would go a long way.
Currently I will use the solution suggested in the discussion above, which is to call the context prop as a function (feels kind of weird, but it works)
My confusion was that Props has first-class support and was very easy to add from the context object, it took me 10 minutes. But for emitting our own events from the component, there is almost nothing :(
I'd love to know if there is an 'official' Formkit way to emit events from inputs? Am I doing this all wrong?
Thank you for the great work on FormKit! If there is anything I can do to help contribute, let me know. Maybe even adding a link to the Github discussion in the documentation, would already save someone else a lot of searching.
Cheers.
The text was updated successfully, but these errors were encountered: