src/js/form-builder.js
function(name, optionData, multipleSelect) {
    const optionInputType = {
      selected: multipleSelect ? 'checkbox' : 'radio',
    }
    const optionDataOrder = ['value', 'label', 'selected']
    const optionInputs = []
    const optionTemplate = { selected: false, label: '', value: '' }

    optionData = Object.assign(optionTemplate, optionData)

    for (let i = optionDataOrder.length - 1; i >= 0; i--) {
      const prop = optionDataOrder[i]
      if (optionData.hasOwnProperty(prop)) {
        const attrs = {
          type: optionInputType[prop] || 'text',
          className: 'option-' + prop,
          value: optionData[prop],
          name: name + '-option',
        }

        attrs.placeholder = mi18n.get(`placeholder.${prop}`) || ''

        if (prop === 'selected' && optionData.selected === true) {
          attrs.checked = optionData.selected
        }

        optionInputs.push(m('input', null, attrs))
      }
    }

    const removeAttrs = {
      className: 'remove btn icon-cancel',
      title: mi18n.get('removeMessage'),
    }
    optionInputs.push(m('a', null, removeAttrs))

    return m('li', optionInputs).outerHTML
  }
function(name, optionData, multipleSelect) {
    const optionInputType = {
      selected: multipleSelect ? 'checkbox' : 'radio',
    }
    const optionDataOrder = ['value', 'label', 'selected']
    const optionInputs = []
    const optionTemplate = { selected: false, label: '', value: '' }

    optionData = Object.assign(optionTemplate, optionData)

    for (let i = optionDataOrder.length - 1; i >= 0; i--) {
      const prop = optionDataOrder[i]
      if (optionData.hasOwnProperty(prop)) {
        const attrs = {
          type: optionInputType[prop] || 'text',
          className: 'option-' + prop,
          value: optionData[prop],
          name: name + '-option',
        }

        attrs.placeholder = mi18n.get(`placeholder.${prop}`) || ''

        if (prop === 'selected' && optionData.selected === true) {
          attrs.checked = optionData.selected
        }

        optionInputs.push(m('input', null, attrs))
      }
    }

    const removeAttrs = {
      className: 'remove btn icon-cancel',
      title: mi18n.get('removeMessage'),
    }
    optionInputs.push(m('a', null, removeAttrs))

    return m('li', optionInputs).outerHTML
  }
function ( name , optionData , multipleSelect ) { const optionInputType = { selected : multipleSelect ? 'checkbox' : 'radio' , } const optionDataOrder = [ 'value' , 'label' , 'selected' ] const optionInputs = [ ] const optionTemplate = { selected : false , label : '' , value : '' } optionData = Object . assign ( optionTemplate , optionData ) for ( let i = optionDataOrder . length - 1 ; i >= 0 ; i -- ) { const prop = optionDataOrder [ i ] if ( optionData . hasOwnProperty ( prop ) ) { const attrs = { type : optionInputType [ prop ] || 'text' , className : 'option-' + prop , value : optionData [ prop ] , name : name + '-option' , } attrs . placeholder = mi18n . get ( ` ${ prop } ` ) || '' if ( prop === 'selected' && optionData . selected === true ) { attrs . checked = optionData . selected } optionInputs . push ( m ( 'input' , null , attrs ) ) } } const removeAttrs = { className : 'remove btn icon-cancel' , title : mi18n . get ( 'removeMessage' ) , } optionInputs . push ( m ( 'a' , null , removeAttrs ) ) return m ( 'li' , optionInputs ) . outerHTML }
Select field html, since there may be multiple
Select field html since there may be multiple