Giter Club home page Giter Club logo

custom-renderer's Issues

Question

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.

Environment

Please provide as many details as you can:

  • Hosting type
    • [] Form.io
    • Local deployment
      • Version:
        {
        version: "6.7.2",
        schema: "3.3.3"
        }
  • Formio.js version: 3.27.3
  • Frontend framework: Vuejs
  • Browser: Chrome
  • Browser version: Version 76.0.3809.132 (Official Build) (64-bit)

Steps to Reproduce

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);

Expected behavior

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

Observed behavior

2 works, the new textfield component was updated.
1 doesn't seem to affect the base component at all

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.