1515 */
1616import { request , RequestOptions } from '../Ajax' ;
1717import { buildURL } from '../ActionURL' ;
18- import { getCallbackWrapper , getOnFailure , getOnSuccess , RequestCallbackOptions } from '../Utils' ;
18+ import { encodeFormName , getCallbackWrapper , getOnFailure , getOnSuccess , RequestCallbackOptions } from '../Utils' ;
1919import { AuditBehaviorTypes } from '../constants' ;
2020
2121export interface QueryRequestOptions extends RequestCallbackOptions {
@@ -273,18 +273,17 @@ export interface SaveRowsResponse {
273273}
274274
275275export interface SaveRowsOptions extends RequestCallbackOptions < SaveRowsResponse > {
276-
277- /**
278- * Optional audit details to record in the transaction audit log for this command.
279- */
280- auditDetails ?: Record < string , any > ;
281276 /**
282277 * Version of the API. If this is 13.2 or higher, a request that fails
283278 * validation will be returned as a successful response. Use the 'errorCount' and 'committed' properties in the
284279 * response to tell if it committed or not. If this is 13.1 or lower (or unspecified), the failure callback
285280 * will be invoked instead in the event of a validation failure.
286281 */
287- apiVersion ?: string | number ;
282+ apiVersion ?: number | string ;
283+ /**
284+ * Optional audit details to record in the transaction audit log for this command.
285+ */
286+ auditDetails ?: Record < string , any > ;
288287 /** An array of the update/insert/delete operations to be performed. */
289288 commands : Command [ ] ;
290289 /**
@@ -303,15 +302,14 @@ export interface SaveRowsOptions extends RequestCallbackOptions<SaveRowsResponse
303302 */
304303 timeout ?: number ;
305304 /**
306- * Whether all of the row changes for all of the tables
307- * should be done in a single transaction, so they all succeed or all fail. Defaults to true.
305+ * Whether all the row changes for all the tables should be done in a single transaction,
306+ * so they all succeed or all fail. Defaults to true.
308307 */
309308 transacted ?: boolean ;
310309 /**
311- * Whether or not the server should attempt proceed through all of the
312- * commands, but not actually commit them to the database. Useful for scenarios like giving incremental
313- * validation feedback as a user fills out a UI form, but not actually save anything until they explicitly request
314- * a save.
310+ * Whether the server should attempt to proceed through all the commands but not commit them to the database.
311+ * Useful for scenarios like giving incremental validation feedback as a user fills out a UI form but does not save
312+ * anything until they explicitly request a save.
315313 */
316314 validateOnly ?: boolean ;
317315}
@@ -336,7 +334,7 @@ function bindSaveRowsCommand(form: FormData, command: Command, commandIndex: num
336334
337335 Object . keys ( updatedRow ) . forEach ( key => {
338336 if ( updatedRow [ key ] instanceof File ) {
339- form . append ( `${ key } ::${ commandIndex } ::${ rowIndex } ` , updatedRow [ key ] ) ;
337+ form . append ( `${ encodeFormName ( key ) } ::${ commandIndex } ::${ rowIndex } ` , updatedRow [ key ] ) ;
340338 delete updatedRow [ key ] ;
341339 }
342340 } ) ;
@@ -420,7 +418,7 @@ export function bindFormData(jsonData: { rows?: any[] }, options: SendRequestOpt
420418 form = new FormData ( ) ;
421419
422420 // Process and extract File data with row offsets
423- const rows : Array < Record < string , any > > = [ ] ;
421+ const rows : Record < string , any > [ ] = [ ] ;
424422
425423 jsonData . rows . forEach ( ( row , i ) => {
426424 if ( row ) {
@@ -429,7 +427,7 @@ export function bindFormData(jsonData: { rows?: any[] }, options: SendRequestOpt
429427 Object . keys ( row ) . forEach ( k => {
430428 // Extract File values from the row
431429 if ( row [ k ] instanceof File ) {
432- form . append ( `${ k } ::${ i } ` , row [ k ] ) ;
430+ form . append ( `${ encodeFormName ( k ) } ::${ i } ` , row [ k ] ) ;
433431 } else {
434432 _row [ k ] = row [ k ] ;
435433 }
0 commit comments