 
 buildFields = (element) ->
   tsFields = element.data('tsFields')
+  tsFieldTypes = {}
   inputs = ''
   model = window.TS.getModel element.data('ts-url')
   modelValues = element.data('ts-data')['ts_values']
 
   for field in tsFields
+    tsFieldTypes[field.name] = field.type
     label = "<label for='#{field.name}'>#{field.label}</label>"
     input = switch field.type
       when "text" then "<input type='text' name='#{field.name}' id='#{field.name}' value='#{modelValues[field.name]}' />"

        select 
    inputs += "<div class'vex-custom-field-wrapper'>#{label}<div class='vex-custom-input-wrapper'>#{input}</div></div>"

  inputs

class window.TS.EditPage

        callback: (data) ->
          if data
            $el = @$element
            tsFieldTypes = $el.data('tsFieldTypes')
            model = window.TS.getModel $el.data('ts-url')
          
            vex.dialog.confirm
