← All changes
|
assets/src/js/frontend/course-builder/builder-course/builder-edit-course.js
+22
-2
4.3.7
→
4.4.9
View file →
| @@ -1352,8 +1352,17 @@ | ||
| 1352 | 1352 | } else if ( element.type === 'radio' ) { |
| 1353 | 1353 | if ( element.checked ) { |
| 1354 | 1354 | data[ fieldName ] = element.value; |
| 1355 | 1355 | } |
| 1356 | + } else if ( element.type === 'select-multiple' ) { | |
| 1357 | + // Collect every selected option, not just the first one (element.value). | |
| 1358 | + const selectedValues = Array.from( element.selectedOptions ) | |
| 1359 | + .map( ( option ) => option.value ) | |
| 1360 | + .filter( ( value ) => value !== '' ); | |
| 1361 | + if ( ! Array.isArray( data[ fieldName ] ) ) { | |
| 1362 | + data[ fieldName ] = []; | |
| 1363 | + } | |
| 1364 | + data[ fieldName ].push( ...selectedValues ); | |
| 1356 | 1365 | } else if ( element.type === 'file' ) { |
| 1357 | 1366 | if ( element.files && element.files.length > 0 ) { |
| 1358 | 1367 | data[ fieldName ] = element.files; |
| 1359 | 1368 | } |
| @@ -1375,10 +1384,21 @@ | ||
| 1375 | 1384 | } ); |
| 1376 | 1385 | } |
| 1377 | 1386 | |
| 1378 | 1387 | // Convert settings arrays to comma-separated strings for API |
| 1379 | - // Exclude course_categories and course_tags - they're handled separately | |
| 1380 | - const excludeFromConversion = [ 'course_categories', 'course_tags' ]; | |
| 1388 | + // Exclude course_categories and course_tags - they're handled separately. | |
| 1389 | + // Exclude the extra-info fields too: their values are free text that may | |
| 1390 | + // contain commas, so they must stay as arrays (one entry per input) and | |
| 1391 | + // not be comma-joined, or the server splits a single value into several. | |
| 1392 | + const excludeFromConversion = [ | |
| 1393 | + 'course_categories', | |
| 1394 | + 'course_tags', | |
| 1395 | + '_lp_requirements', | |
| 1396 | + '_lp_target_audiences', | |
| 1397 | + '_lp_key_features', | |
| 1398 | + '_lp_faqs_question', | |
| 1399 | + '_lp_faqs_answer', | |
| 1400 | + ]; | |
| 1381 | 1401 | Object.keys( data ).forEach( ( key ) => { |
| 1382 | 1402 | if ( Array.isArray( data[ key ] ) && ! excludeFromConversion.includes( key ) ) { |
| 1383 | 1403 | data[ key ] = data[ key ].join( ',' ); |
| 1384 | 1404 | } |