We have two field based on first field I want to set the value of second and it is upto the user to use the set value or may insert a new one and submit the form.
Now in CustomField class dependsOn() method I can access, the dependsOn field name, that is field_1, also in Vue > FormField.vue I can access it as {{ field.dependsOnField }} in template and as console.log(this.field.dependsOnField); in JS part, but how I can get the value of field_1 and also on change I can get new value, I am new to Vue JS, but I tried it like
export default {
mounted() {
this.registerDependencyWatchers(this.$root)
},
methods: {
registerDependencyWatchers(root) {
console.log(this.field.dependsOnField);
root.$children.forEach(component => {
if (this.componentIsDependency(component)) {
console.log(component.$attrs);
component.$watch('value', async (value) => {
console.log('working 2');
this.registerDependencyWatchers(component)
});
}
});
},
componentIsDependency(component) {
console.log(component);
console.log(component.$attrs);
console.log(component.field);
if(component.field === undefined) {
return false;
}
for (let dependency of this.field.dependsOnField) {
console.log(dependency);
if(component.field.attribute === dependency.field) {
return true;
}
}
return false;
},
}
} `componentIsDependency` is always returning false as `component.field` is undefined and if I am returing true there `component.$watch('value', async (value) => {` is not running, I coded it by taking reference from [NovaDependencyConatiner][1] package.
custom field issue
We have two field based on first field I want to set the value of second and it is upto the user to use the set value or may insert a new one and submit the form.
-adding custom field like
Now in
CustomField
classdependsOn()
method I can access, the dependsOn field name, that isfield_1
, also in Vue > FormField.vue I can access it as{{ field.dependsOnField }}
in template and asconsole.log(this.field.dependsOnField);
in JS part, but how I can get the value offield_1
and also on change I can get new value, I am new to Vue JS, but I tried it likeConsole.log(component)
is something like