Comments (8)
Hey @datenspast thanks I'm on vacation I'll check it out when I get back ๐
from formvuelate.
Thanks for the repro @datenspast
@logaretm i have a feeling somewhere around ln 58-64 were conflicting in the parsing bc on ParsedSchema ln 104 I need a way to identify the name. I guess maybe we could try changing that condition to check for a .schema
also.
Wdyt?
from formvuelate.
Hey @datenspast try changing the component: SchemaForm, // this works
for component: SchemaFormWithPlugins,
since each level of the nested schema needs to have access to the plugin implementation
https://codesandbox.io/s/fvl-nested-schema-3-x-forked-r16hz?file=/src/App.vue:869-906
Is that what you were expecting?
from formvuelate.
Hi @marina-mosti : Many thanks for your reply and support!
Your proposed solution works but does not solve the issue Iยดm facing.
Since we get the Schema from an API all values are Strings. So we get e.g.
{
model: "firstName",
component: "Text",
label: "First Name",
},
{
model: "nested",
component: "SchemaForm", // we get this as a String
schema: [
{
model: "nestedfirstName",
component: "Text", // we get this as a String
label: "First Name nested",
},
],
},
I understand the guide (https://formvuelate.js.org/guide/lookup.html#nested-schema-caveats) that it is also possible to use Strings and map them to the component (SchemaFromWithPlugins in my case):
{
"firstName": {
"component": "string",
"info": "First Name"
},
"work": {
"component": "SchemaForm",
"schema": {
"address": {
"type": "FormText",
"label": "Work address"
},
"details": {
"component": "SchemaForm",
"schema": {
"position": {
"type": "FormText",
"label": "Work position"
}
}
}
}
}
}
// Note "SchemaFormWithPlugin" getting remapped
const SchemaFormWithPlugin = SchemaFormFactory([
LookupPlugin({
SchemaForm: 'SchemaFormWithPlugin', // is the "mapComponents" not included by intention here? I tried it this way but it did not work as well.
[...]
}
})
])
from formvuelate.
@datenspast are you importing components globally? or locally into this file?
Did you check out this caveat: https://formvuelate.js.org/guide/plugins.html#using-locally-imported-components ?
from formvuelate.
So:
SchemaForm: "SchemaFormWithPlugins",
This inside mapComponents
can not work, because the component SchemaFormWithPlugins
is not globally registered or passed down the schema tree.
Its literally a constant inside your component, so subcomponents have no way of knowing about it.
SchemaFormFactory
takes a second param components
that registers components in child schema forms or nested schemas. The problem here is that you cant really make the factory a child of itself ๐
I don't see right now any other way of solving this other than you doing a pre-lookup-plugin parsing of the internal schema.component
properties into the name of your constant before you feed it your schema
.
I'm honestly trying to remember how it worked when I wrote this piece of docs, but ill do more research and try to figure it out and/or delete the documentation which is misleading.
PS: Didnt mean to close, reopening :)
from formvuelate.
@datenspast are you importing components globally? or locally into this file?
I`m importing components locally into this file.
Did you check out this caveat: https://formvuelate.js.org/guide/plugins.html#using-locally-imported-components ?
I tried to make some changes based on this, but did not manage to solve the issue.
I don't see right now any other way of solving this other than you doing a pre-lookup-plugin parsing of the internal
schema.component properties into the name of your constant before you feed it your schema.
Yes, that approach seems to work. I tried this here:
https://codesandbox.io/s/fvl-nested-schema-3-x-forked-c05qr?file=/src/App.vue
@marina-mosti : Many thanks for addressing this issue by adding it as a new feature into the library.
from formvuelate.
Hi @logaretm and @marina-mosti!
I am really sorry to bug you again but the new Feature does not seem to work if the VeeValidatePlugin
is also used.
Or do I miss anything?
const SchemaFormWithPlugins = SchemaFormFactory([
LookupPlugin({
mapComponents: {
Text: FormText,
},
}),
// if this is included, the nested schema is not displayed.
VeeValidatePlugin({
}),
]);
const SCHEMA = [
{
model: "firstName",
component: "Text",
label: "First Name",
},
{
model: "nested",
component: "SchemaForm",
schema: [
{
model: "nestedfirstName",
component: "Text", // does not work
// component: FormText, // Works if VeeValidatePlugin is included
label: "First Name nested",
},
],
},
];
Please find an example here:
https://codesandbox.io/s/fvl-nested-schema-3-x-forked-5o1jt?file=/src/App.vue
Many thanks again for your help (I owe you a forest...)
from formvuelate.
Related Issues (20)
- Unexpected token with v3.6.0
- Locally imported components not working HOT 3
- Default values with value "false" are not added to model during initialisation HOT 1
- Load schema from json source HOT 2
- custom element for form HOT 1
- Wrap fields into a div inside form tag? HOT 2
- Using formvuelate + vee-validate one_of rule HOT 5
- Vue warns "inject() can only be used inside setup() or functional components." when trying to insert new object or array. HOT 3
- Add Support for (repeatable) Field Groups HOT 2
- Console warning with locally imported components
- Using local imports with Vee Validate plugin does not render form HOT 3
- codesandbox examples not working HOT 1
- Nested schemas with default values HOT 1
- Code sandbox is broken HOT 1
- How to trigger validate manually? HOT 6
- Unable to set validation for vee-validate HOT 2
- Expose or bind to change on validation meta and errors HOT 4
- Add custom class for each schema-row HOT 7
- Vue warns "provide() can only be used inside setup()" when calling "useSchemaForm()" inside a function.
- Dirrective
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formvuelate.