       # Form doc is the full set of fields which the doc supports. We must avoid creating modifiers
       # containing any other fields, since this form does not affect them.
       keys = _.keys(formDoc)
-      changes = {}
-      _.each keys, (key) ->
-        formValue = Forms._sanitizeCompareValue(formDoc[key])
-        prevValue = Forms._sanitizeCompareValue(prevFormDoc[key])
-        if formValue != prevValue
-          # Ensure empty values are null.
-          changes[key] = formValue || null
-      changes
+      changes = Forms._getObjectChanges(prevFormDoc, formDoc)
+      # Ensure object values are flattened.
+      Objects.flattenProperties(changes)
 
     # Merges the latest document into the form, giving precedence to the changed values in the form.
     # @returns {Object} The flattened properties of the latest document which were merged into the

    else
      $input.prop('readonly', disabled)

  _sanitizeCompareValue: (value) -> value?.toString().trim() ? ''

  getInputId: ($input) -> $input.attr('data-schema-key')


      $inputs.each ->
        $input = $(@)
        id = Forms.getInputId($input)
        value = Form.getInputValue($input)
        values[id] = value
      values

    Form.getInputValue = ($input) -> Forms.getInputValue($input, Form.getSchema())

    Form.setSubmitButtonDisabled = (disabled, template) ->
      Form.getSubmitButton(template).toggleClass('disabled', !!disabled)
