formio / custom-renderer Goto Github PK
View Code? Open in Web Editor NEWAn example custom renderer that extends the Form.io core renderer.
An example custom renderer that extends the Form.io core renderer.
Hi,
i'm building a Vue form app based on Vue-formio and structured similar to React Formio App.
I'm trying to customize the renderer and hitting a few issues.
Please provide as many details as you can:
newBase.js
import BaseComponent from 'formiojs/components/base/Base';
const baseCreateElement = BaseComponent.prototype.createElement;
BaseComponent.prototype.createElement = function createElement() {
if (this.element) {
//update class for case when Logic changed container class (customClass)
this.element.className = this.className;
return this.element;
}
this.element = this.ce('div', {
class: this.className,
style: this.customStyle
});
console.log(this.element);
// Ensure you can get the component info from the element.
this.element.component = this;
this.hook('element', this.element);
return this.element;
}
export default BaseComponent;
newTextField.js
import TextFieldComponent from 'formiojs/components/textfield/TextField';
export class NewTextFieldComponent extends TextFieldComponent {
// Override the createLabel method.
createLabel(container) {
super.createLabel(container);
this.addClass(this.labelElement, 'ott-text-field');
}
}
Form.ts (based on vue-formio)
import BaseComponent from '../NewRenderer/newBase.js';
// Register all the components which will use the new BaseComponent provided above.
import AllComponents from 'formiojs/components';
import NewTextFieldComponent from '../NewRenderer/newTextField.js'
// Use our extended textfield component.
AllComponents.textfield = NewTextFieldComponent;
import Components from 'formiojs/components/Components';
Components.setComponents(AllComponents);
1.If the changes in BaseComponent is applied there should be console.log prints
2.The rendered textfield should have class ott-text-field added
2 works, the new textfield component was updated.
1 doesn't seem to affect the base component at all
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.