 			// form element for object(s)
 			loc.returnValue = ListLast(arguments.objectName, ".");
 			if (Find("[", loc.returnValue))
-			{
-				// this is a form element for an array of objects so we replace the array position with the primary key value of the object (unless the object is new and has no primary key set)
-				loc.key = $getObject(arguments.objectName).key();
-				if (Len(loc.key))
-					loc.returnValue = ListFirst(loc.returnValue, "[") & "-" & $getObject(arguments.objectName).key();
-				else
-					loc.returnValue = ReplaceList(loc.returnValue, "[,]", "-,");
-			}
-			loc.returnValue = loc.returnValue & "-" & arguments.property;
-		}
-		else
-		{
-			// this is a non object form element
-			loc.returnValue = ReplaceList(arguments.property, "[,]", "-,");
+				loc.returnValue = $swapArrayPositionsForIds(objectName=loc.returnValue);
+			if (Find("[", arguments.property))
+				loc.returnValue = REReplace(REReplace(loc.returnValue & arguments.property, "[,\[]", "-", "all"), "[""'\]]", "", "all");
+			else
+				loc.returnValue = REReplace(REReplace(loc.returnValue & "-" & arguments.property, "[,\[]", "-", "all"), "[""'\]]", "", "all");
+			if (Find("--", loc.returnValue)) // we have a new object and we don't want to repeat ids
+				loc.returnValue = Replace(loc.returnValue, "--", "-new-" & $getNewObjectCount(loc.returnValue) & "-", "all");
+		}
+		else
+		{
+			loc.returnValue = ReplaceList(arguments.property, "[,],',""", "-,");
 		}
 	</cfscript>
 	<cfreturn loc.returnValue>

		{
			loc.returnValue = ListLast(arguments.objectName, ".");
			if (Find("[", loc.returnValue))
			{
				loc.key = $getObject(arguments.objectName).key();
				if (Len(loc.key))
					loc.returnValue = ListFirst(loc.returnValue, "[") & "[" & loc.key & "]";
			}
			loc.returnValue = loc.returnValue & "[" & arguments.property & "]";
		}
		else
		{
			loc.returnValue = arguments.property;
		}
	</cfscript>
	<cfreturn loc.returnValue>
</cffunction>

<cffunction name="$addToJavaScriptAttribute" returntype="string" access="public" output="false">

<cffunction name="$getObject" returntype="any" access="public" output="false" hint="Returns the object referenced by the variable name passed in. If the scope is included it gets it from there, otherwise it gets it from the variables scope.">
	<cfargument name="objectName" type="string" required="true">
	<cfscript>
		var loc = {};
		loc.returnValue = "";
		
		if (Find(".", arguments.objectName) or Find("[", arguments.objectName)) // we can't directly invoke objects in structure or arrays of objects so we must evaluate
		{
			if (ReFind("\[\]", arguments.objectName)) // we have an array object without a postion so create a new object to return
			{
				loc.array = ListToArray(ReplaceList(arguments.objectName, "],'", ""), "[", false);
				loc.returnValue = $invoke(componentReference=model(singularize(loc.array[ArrayLen(loc.array)])), method="new");
			}
			else
			{
				loc.returnValue = Evaluate(arguments.objectName);
			}
		}
		else
		{
			loc.returnValue = variables[arguments.objectName];
		}
	</cfscript>
	<cfreturn loc.returnValue>
</cffunction>

<cffunction name="$getNewObjectCount" returntype="numeric" access="public" output="false">
	<cfargument name="id" type="string" required="true" />
	<cfscript>
		if (!StructKeyExists(request.wheels, "counts"))
			request.wheels.counts = {};
		if (!StructKeyExists(request.wheels.counts, arguments.id))
			request.wheels.counts[arguments.id] = 0;
		request.wheels.counts[arguments.id]++;
	</cfscript>
	<cfreturn request.wheels.counts[arguments.id] />
</cffunction>
