-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
Schema reactivity #802
Comments
Yes, you probably still need the workaround. The error can sometimes appear in the demo pkg, too. At some point I can probably make it work properly, but it's difficult to debug the blaze reactivity stuff. |
Hi @elGusto, which workaround trick are you referring to? |
@Gigacross I am talking about this https://github.com/aldeed/autoform-demo/blob/master/client/views/quickform/quickform.html#L57-L59 Based on the code that you provided, I am not able to tell what you are doing wrong. Are you giving the schema to autoform with a helper using your reactiveVar.get()? @aldeed Alright thanks for the tip! Yeah I started doing that but quickly gave up since I just started to get into blaze with arunoda's book. |
@elGusto Thanks! I implemented that work around but I'm still getting errors, not entirely sure where I went wrong... basically the idea is to delete the whole form, and recreate it. I managed to find out how it was implemented after looking at the example code provided in the demo, so I managed to successfully implement dynamic schema, hence I removed my reply here. But now I don't know how to change the key / rename the title of the key i.e. I think I have to make a full layer between user and making the schema, so basically user -> buildSchemaPkg -> generate schema -> feed into autoform, all my attempts to create a dynamic form properly has been futile... that way autoform don't really have to deal with all the reactivity also... |
@Gigacross I am also working on the exact thing. I didn't get there yet but will later today if all is good. I will update here when I can really give you an answer. |
@elGusto Cool! In the meantime I'll also attempt to create that myself, may be not build into a full package, but I'll be able to put a gist together or something, if you happen to accomplish it before I do, let me know! Thanks in advance :) |
The workaround is no longer working for me on version 5. I'll see if I can track down a fix. |
Nevermind, the concept of the workaround still works for me. I ended up making the schema a ReactiveVar so I can control when it changes. First I set destroyForm to true, which will cause the template to remove the existing autoForm from the DOM, then I set the schema var to the NEW schema, and then the second computation fires to set destroyForm back to false. It still feels horrible doing it this way, as the timing is ambiguous but this pattern seems to be working for me.
|
Yep this is it but I still get the errors like before, the workaround didn't correct the bug which occurs only when a field is removed from the schema. I made a package to create autoform schemas with the UI. The goal is to provide a simple form builder that then could be used to create some sort of CMS system. It is still in the (very) early stage but I will publish it soon enough when I have time to clean some stuff out. |
Ive built a similar AF schema builder in a proprietary app I'm making.
|
I have prepared a branch of autoform that allows for the schema to be reactive. It's not an ideal solution, but this may work for our needs. I would appreciate any help you can provide in testing the branch. I wouldn't recommend it for production until it is tested further. https://github.com/abecks/meteor-autoform/tree/reactive-schema Using this branch, you can return a SimpleSchema object to the
I've made as few changes as possible. The problem lies in how the AutoForm context is passed around to field template helpers. Field's grab their "AutoForm context" from calls to A change in schema will cause all of the fields in the form to re-render. The problem is that the helper's reactive dependency on My branch adds a few checks and try/catch enclosures to prevent fields from throwing errors when they no longer exist in the schema. |
I've just ran across a similar issue when changing the schema reactively, I assume this fix hasn't made it into core yet @abecks? |
Not yet. Sorry guys. Will try to resubmit my PR soon. You can always take
|
Resubmitted my PR, watch #1132 for updates. |
@abecks 👍 thanks man! |
@abecks any new with this PR? |
PR has been merged. Will release new version soon. |
I have a quickForm rendered with the schema option and my schema is constructed from a reactive-var. Very much like the code in the autoform-demo package.
It is almost working but I am experiencing an error when a field is removed from the schema.
Adding fields works like a charm but removing it throws error for every autoform template related to the field being removed.
And this goes on...
I thought my error was related to #794 but I still have the error after the update this morning.
Should I use the workaround trick you used in the autoform-demo package ?
The text was updated successfully, but these errors were encountered: