src/js/form-builder.js
function selectUserAttrs(name, fieldData) {
    const { multiple, options, label: labelText, value, class: classname, className, ...restData } = fieldData
    const optis = Object.keys(options).map(val => {
      const attrs = { value: val }
      const optionTextVal = options[val]
      const optionText = Array.isArray(optionTextVal) ? mi18n.get(...optionTextVal) || optionTextVal[0] : optionTextVal
      if (Array.isArray(value) ? value.includes(val) : val === value) {
        attrs.selected = null
      }

      return m('option', optionText, attrs)
    })

    const selectAttrs = {
      id: `${name}-${data.lastID}`,
      title: restData.description || labelText || name.toUpperCase(),
      name,
      className: `fld-${name} form-control ${classname || className || ''}`.trim(),
    }

    if (multiple) {
      selectAttrs.multiple = true
    }

    const label = `<label for="${selectAttrs.id}">${i18n[name]}</label>`

    Object.keys(restData).forEach(function(attr) {
      selectAttrs[attr] = restData[attr]
    })

    const select = m('select', optis, selectAttrs).outerHTML
    const inputWrap = `<div class="input-wrap">${select}</div>`
    return `<div class="form-group ${name}-wrap">${label}${inputWrap}</div>`
  }
function selectUserAttrs(name, fieldData) {
    const { multiple, options, label: labelText, value, class: classname, className, ...restData } = fieldData
    const optis = Object.keys(options).map(val => {
      const attrs = { value: val }
      const optionTextVal = options[val]
      const optionText = Array.isArray(optionTextVal) ? mi18n.get(...optionTextVal) || optionTextVal[0] : optionTextVal
      if (Array.isArray(value) ? value.includes(val) : val === value) {
        attrs.selected = null
      }

      return m('option', optionText, attrs)
    })

    const selectAttrs = {
      id: `${name}-${data.lastID}`,
      title: restData.description || labelText || name.toUpperCase(),
      name,
      className: `fld-${name} form-control ${classname || className || ''}`.trim(),
    }

    if (multiple) {
      selectAttrs.multiple = true
    }

    const label = `<label for="${selectAttrs.id}">${i18n[name]}</label>`

    Object.keys(restData).forEach(function(attr) {
      selectAttrs[attr] = restData[attr]
    })

    const select = m('select', optis, selectAttrs).outerHTML
    const inputWrap = `<div class="input-wrap">${select}</div>`
    return `<div class="form-group ${name}-wrap">${label}${inputWrap}</div>`
  }
function selectUserAttrs ( name , fieldData ) { const { multiple , options , label : labelText , value , class : classname , className , ... restData } = fieldData const optis = Object . keys ( options ) . map ( val => { const attrs = { value : val } const optionTextVal = options [ val ] const optionText = Array . isArray ( optionTextVal ) ? mi18n . get ( ... optionTextVal ) || optionTextVal [ 0 ] : optionTextVal if ( Array . isArray ( value ) ? value . includes ( val ) : val === value ) { attrs . selected = null } return m ( 'option' , optionText , attrs ) } ) const selectAttrs = { id : ` ${ name } ${ data . lastID } ` , title : restData . description || labelText || name . toUpperCase ( ) , name , className : ` ${ name } ${ classname || className || '' } ` . trim ( ) , } if ( multiple ) { selectAttrs . multiple = true } const label = ` ${ selectAttrs . id } ${ i18n [ name ] } ` Object . keys ( restData ) . forEach ( function ( attr ) { selectAttrs [ attr ] = restData [ attr ] } ) const select = m ( 'select' , optis , selectAttrs ) . outerHTML const inputWrap = ` ${ select } ` return ` ${ name } ${ label } ${ inputWrap } ` }
Select input for multiple choice user attributes
@todo  replace with selectAttr
@param  {String} name
@param  {Object} fieldData
@return {String}         select markup
Select input for multiple choice user attributes