render(element = null, instanceIndex = 0) {
    const formRender = this
    const opts = this.options
    element = this.getElement(element)

    const runCallbacks = function () {
      if (opts.onRender) {
        opts.onRender()
      }
    }

    // Begin the core plugin
    const rendered = []

    // instantiate the layout class & loop through the field configuration
    const engine = new opts.layout(opts.layoutTemplates, false, opts.disableHTMLLabels, opts.controlConfig)
    if (opts.formData.length) {
      for (let i = 0; i < opts.formData.length; i++) {
        const fieldData = opts.formData[i]
        const sanitizedField = this.sanitizeField(fieldData, instanceIndex)

        // determine the control class for this type, and then process it through the layout engine
        const controlClass = this.templatedControls.getClass(fieldData.type) || control.getClass(fieldData.type, fieldData.subtype)
        const field = engine.build(controlClass, sanitizedField)

        rendered.push(field)
      }
    } else {
      opts.notify.warning(opts.messages.noFormData)
    }

    if (element) {
      this.instanceContainers[instanceIndex] = element
    }

    // if rendering, inject the fields into the specified wrapper container/element
    if (opts.render && element) {
      element.emptyContainer()
      element.appendFormFields(rendered)

      runCallbacks()
      opts.notify.success(opts.messages.formRendered)
    } else {
      /**
       * Retrieve the html markup for a passed array of DomElements
       * @param {Array} fields - array of dom elements
       * @return {string} fields html
       */
      const exportMarkup = fields => fields.map(elem => elem.innerHTML).join('')
      formRender.markup = exportMarkup(rendered)
    }

    if (opts.disableInjectedStyle === true) {
      const styleTags = document.getElementsByClassName('formBuilder-injected-style')
      forEach(styleTags, i => remove(styleTags[i]))
    } else if (opts.disableInjectedStyle === 'bootstrap' && opts.render && element) {
      element.getElementsByClassName('formbuilder-embedded-bootstrap').item(0)?.classList.remove('formbuilder-embedded-bootstrap')
    }
    return formRender
  }
Main render method which produces the form from passed configuration
@param {Object} element - an html element to render the form into (optional)
@param {number} instanceIndex - instance index
@return {Object} rendered form