-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Functions in JSON #117
Comments
I've found this and modified it to my needs, which seems then to work so far. |
@Bruno17 yeah. this is a limitation of JSON which is better solved outside of Blitzar 😅 Could you add something on this to the documentation? We could add it somewhere on the advanced page: there are edit on github links at the bottom of the documentation now! 🎉 |
I think Blitzar schema syntax should be a valid JSON (as such can be stored in database). For example:
|
@layanto Coming up with an entire set of possible validation rules in just plain text to then apply some sort of validation system on top of Blitzar is a lot of work and I would ideally just go with the most popular solution that already provides this, and integrate that into Blitzar. This would require a lot of research into libraries, what they provide exactly, how flexible they are for integration into Blitzar, how popular they are, if they have security issues or not, etc.etc. I don't think I'll have the time to do this TBH. 😅 If you want to build an admin panel where your users can create and save their own forms, and provide some pre-made validation logic that they can apply to those forms, I think it's really easy to just define those rules as JS functions client side, and save them by some sort of ID in your user's database and then just replace them when you get their schema from the database again. Other than this, I'm not able to think of anything actionable atm. I'd love to hear your thoughts! |
I do love the flexibility of dynamic props for validation and logic to hide/show or enable/disable form elements. I still wish there is an easy way to store the schema as string in database and restore the schema from database. |
How about using this library for dynamic props? Functions in dynamic props are expressed as string (as such can be stored as json) and at run time evaluated via expr-eval library. This limits the flexibility of dynamic props to functions supported by expr-eval but maybe still powerful enough for most use cases? |
my solution looks like that: then I can store functions as string like that: |
@mesqueeb If a dynamic prop (i.e. listed in the dynamicProps) is NOT of type string, then do the current behaviour.
Since the dynamic prop 'function' is stored as string, this can be converted to JSON and stored in database. I have tested the following as string and appeared to work:
|
@layanto i'm open to the idea. Are you willing to make a PR? |
I'm storing form schemas as JSON in a db and fetch that schemas dynamically via ajax, when needed.
In the advanced section of your docs you use functions as values.
Storing Functions in JSON that way is not possible.
Do you know a way, how I could store this functions as string and convert them to functions after fetching or do you have another workaround for that issue?
The text was updated successfully, but these errors were encountered: