register(templates = {}, fields = []) {
    // prepare i18n locale definition
    const locale = mi18n.locale
    if (!this.def.i18n[locale]) {
      this.def.i18n[locale] = {}
    }

    const _this = this
    Object.keys(templates).forEach(templateName => {
      const templateControl = function(config, preview) {
        this.customControl = new controlCustom(config, preview, templates[templateName])

        /**
         * build a custom control defined in the templates option
         * @return {{field: any, layout: any}} DOM Element to be injected into the form.
         */
        this.build = function() {
          return this.customControl.build()
        }

        this.on = function(eventType) {
          return this.customControl.on(eventType)
        }
      }
      templateControl.definition = {}
      templateControl.label = type => _this.label(type)
      templateControl.icon = type => _this.icon(type)
      this.templateControlRegister[templateName] = templateControl
    })

    // build the control label & icon definitions
    for (const field of fields) {
      let type = field.type
      field.attrs = field.attrs || {}
      if (!type) {
        if (!field.attrs.type) {
          control.error('Ignoring invalid custom field definition. Please specify a type property.')
          continue
        }
        type = field.attrs.type
      }

      // default icon & label lookup
      let lookup = field.subtype || type

      // if there is no template defined for this type, check if we already have this type/subtype registered
      if (!templates[type]) {
        // check that this type is already registered
        try {
          const controlClass = control.getClass(type, field.subtype)

          // generate a random key & map the settings against it
          lookup = field.datatype ? field.datatype : `${type}-${Math.floor(Math.random() * 9000 + 1000)}`

          this.customRegister[lookup] = jQuery.extend(field, {
            type: type,
            class: controlClass,
          })
        } catch(e) {
          control.error(
            'Error while registering custom field: ' +
            type +
            (field.subtype ? ':' + field.subtype : '') +
            '. Unable to find any existing defined control or template for rendering.',
          )
        }
      } else {
        //Map the field definition into the templated control class
        const controlClass = this.templateControlRegister[type]
        controlClass.definition = field
        this.customRegister[lookup] = jQuery.extend(field, {
          type: type,
          class: controlClass,
        })
      }

      // map label & icon
      this.def.i18n[locale][lookup] = Array.isArray(field.label) ? mi18n.get(...field.label) || field.label[0] : field.label
      this.def.icon[lookup] = field.icon
    }
  }
Override the register method to allow passing 'templates' configuration data
@param {Object} templates an object/hash of template data as defined https://formbuilder.online/docs/formBuilder/options/templates/
@param {Array} fields