onClick not handling all values
See original GitHub issueReproduction
https://formkit.link/bafcc2084a9cad6394827c2c9e68deb5
Describe the bug
I feel like I have to be doing something stupid here. I’ve been working off the multi-step form example here and sandboxing some new features I need as a proof of concept. The playground example shows a case where an onClick
handler doesn’t seem to handle being passed an object. Open that example, open the dev console, and click the LogObj
button. The definition for that button is:
{
$formkit: 'button',
onClick: '$log({"nextStep":"bla", "test":2})',
children: 'LogObj'
},
The log function is defined in Playground.vue as:
log: target => () => {
console.log('target:', target)
},
In the console I just see: target: {"nextStep":"bla"
.
At one point onClick
was also handling URLs weird for me but now I can’t reproduce that in the playground. Is it possible formkit’s parsing of variables in schema values is having trouble with certain values/types being used there? Am I just wrong in assuming it can evaluate a JS object? Maybe I need to be passing a JSON string and decoding it if I want to get away with something like the above?
Environment
• OS: MacOS • Browser: Chrome • Version: 101.0.4951.64 (Official Build) (x86_64)
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Hey @andrew-boyd, just wanted to note that I took a different approach to this. Instead I just added a “fake” node to the schema that simply holds metadata, and in a wrapper to
FormKitSchema
I look for that and update ameta
field in thedata
value. For example:It doesn’t seem that formkit minds that I put an invalid node in the schema, it just ignores it. This is a lot cleaner than adding groups and hidden inputs IMO.
@totalhack you can also put the
ignore: true
prop on any input and it won’t be included in the posted form data.