           doc
         update: (docId, modifier, template) ->
           console.debug('before update', docId, modifier)
+          # Remove the items in $unset which don't exist as fields in the form.
+          $unset = modifier.$unset
+          if Object.keys($unset).length >= 0
+            schemaInputs = Form.getSchemaInputs(template)
+            fieldIds = []
+            _.each schemaInputs, (input, key) ->
+              fieldIds.push(key) if $(input).length > 0
+            remFieldIds = _.difference(Object.keys($unset), fieldIds)
+            _.each remFieldIds, (fieldId) ->
+              delete $unset[fieldId]
+          console.log('modifier', modifier)
           modifier
 
     if formArgs.hooks?

        field.optional = true
      new SimpleSchema(schemaArgs)

    return Form

  ##################################################################################################

      @autorun (c) ->
        helpMode = Session.get 'helpMode'
        if helpMode then addPopups() else removePopups()

      # if Form.isBulk()
      #   Form.setUpBulkFields()
      
      formArgs.onRender?.apply(@, arguments)

