-
Notifications
You must be signed in to change notification settings - Fork 533
Is it possible to inherit/extend a core field? #232
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
Comments
As far as I know, this is impossible with the current system. There could be a way by using mixins but this is currently not the way this plugin work*. *Most of the code for the fields are shared in the This is only my view on the issue, maybe @icebob has another point of view. |
I wonder, @icebob, do you have another point of view on this? It would of course be better to be able to extend rather than copying and adapting the source. |
@Vacilando |
Yes, it would be good, but in current implementation it is not possible. |
That would be nice, but shouldn't we do something like "VFG engine" and make all fields separate modules. |
Maybe simpler alternatives such as adding component names exporting fields in a separate file
//fields index file export default {Input, Checkbox} etc install(Vue,options) {
Vue.component("VueFormGenerator", module.exports.component);
if(option.fields){
fields.forEach((field)=>{
Vue.component(field.name,field);
})
}
} Usage: import VFG from 'vue-form-generator'
import {Input, Checkbox, AutoComplete} from 'vue-form-generator/fields'
Vue.use(VFG, [Input,Checkbox,Autocomplete]) To me this seems more usable and controllable (in terms of size because webpack does tree-shaking if you do partial imports) rather than installing a new field with npm. Npm packages as fields might be a good idea for direct script includes if you don't need the whole vfg |
@cristijora yes, that was it what I needed. To import a single field and then do whatever I want with it. It's more like project structuring work than implementation of engines and stuff. |
I think you can already do that @random-one by importing it then registering it on vfg directly but what I wrote above would be prettier, cleaner and more straight forward. The disadvantage here is that users will have to import pug if the field implementation is kept as it is |
@cristijora I agree with you that your proposal is better and more straight forward. I couldn't do what you suggested because I'm too new to vue.js and couldn't dug them out of the module. |
@cristijora I like your idea a lot. Could we do that as well ? import VFG from 'vue-form-generator'
import {Input, Checkbox, AutoComplete} from 'vue-form-generator/fields'
import myField from 'custom/myField'
Vue.use(VFG, [Input,Checkbox,Autocomplete, myField]) |
Yes of course. That's the whole purpose of it to register components. Inside the install method it simply |
@icebob Is it too late to implement this solution ? I know you wanted to release v2 this week. |
Hm I already got stuck on this due to some tests issues. Even if I delete the components registration from vueFormGenerator.vue the tests still pass. @icebob any idea ? |
@lionel-bijaoui I don't understand how it will solve the original problem? |
@icebob It doesn't but it make VFG more modular and this is something I convinced is needed (#67 was a first step). The app I'm building is big so we need to trim as much fat as possible. |
I think it needs more time & development, so it comes only in the next major v3.
|
Hello,
my question is if it's possible to inherit(using extends) for example the
fieldSelect
just to include something in its templatе?I don't want to just copy the whole field code and modify it for my needs and use it as a custom field. I think it would be possible if we could import the
fieldsComponents
themselves. Right now in my opinion only theabstractField
mixin is exposed and used when defining custom fields, but that is not my case.My problem with copying the
fieldSelect
and using it as custom field is that when at some point a newer version ofvue-form-generator
fixes something or improves the component, my copy of it has to be maintained by me and manually updated to incorporate the fixes or improvements.Any thoughts on this @icebob?
The text was updated successfully, but these errors were encountered: