koumoul-dev / vuetify-jsonschema-form

Create beautiful and low-effort forms that output valid data. Published on npm as @koumoul/vjsf.
https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/
MIT License
538 stars 154 forks source link

[x-if] expression #322

Closed Meplos closed 2 years ago

Meplos commented 2 years ago

Hey! How to use newFunction expression in an x-if.

theRenard commented 1 year ago

How ?

albanm commented 1 year ago

It is quite hidden in the doc but this example uses newFunction.

Please note that a new function is compiled, but the provided string is not a full function signature, only an expression that will injected after a return statement, see the source code here.

theRenard commented 1 year ago

Thank you @albanm !

Yeah I see, this limits in some way having more javascript logic there... Is this choice by design ?

albanm commented 1 year ago

I think it didn't feel natural to inject multiple line statements, function definitions, etc. A simple string in a JSON file is not the good place to write large chunks of dynamic code. But you should be able to call more complex functions either from the global scope or referenced in options.context.