Skip to content

Adding custom fields #148

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

Closed
reardestani opened this issue Mar 9, 2017 · 5 comments
Closed

Adding custom fields #148

reardestani opened this issue Mar 9, 2017 · 5 comments
Labels

Comments

@reardestani
Copy link

reardestani commented Mar 9, 2017

Hi,

Is it possible to add new custom fields without using webpack, vue-loader, as far as I see I need to do it in a separate file then load it in main app but I am just loading vue and this package via script in my simple app.

For example, how is it possible to do it in the official example?

Thanks in advance,

@icebob
Copy link
Member

icebob commented Mar 9, 2017

This is an example for custom field: https://jsfiddle.net/0mg1v81e/251/

You need to register your field as a global component:

Vue.component("field-myinput", {
    template: '<input type="text" v-model="value" style="width: 100%; border: 2px solid red" />',
    mixins: [ VueFormGenerator.abstractField ]
});

And in the schema use the field name without field- prefix:

{
	type: "myinput",
	label: "My input field",
	model: "msg"
}

@icebob icebob added the question label Mar 9, 2017
@reardestani
Copy link
Author

Thanks man, it works for me.

@reardestani
Copy link
Author

Wondering why the model value is not getting updated in the simple color picker? When I change the value directly from input it works but not when picking a color from color picker.

Example: https://jsfiddle.net/reardestani/0mg1v81e/254/

Screenshot: http://take.ms/yJIyT

Thanks in advance,

@reardestani reardestani reopened this Mar 10, 2017
@icebob
Copy link
Member

icebob commented Mar 10, 2017

It seems bootstrap-colorpicker doesn't trigger the input event on the <input />. So you need to do it manually via picker changeColor event.

https://jsfiddle.net/icebob/0mg1v81e/256/

@reardestani
Copy link
Author

Thanks, cool, I also took another approach and triggered input event on the <input /> in the js codes then added @input="value = $event.target.value" to the <input />.

var event = new Event('input', {
   'bubbles': true,
   'cancelable': true
});

this.dispatchEvent(event);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants