@@ -59,7 +59,13 @@ window.onload = function () {
5959 } ) ;
6060 field . querySelectorAll ( 'select' ) . forEach ( select => {
6161 if ( pathStorage [ field . id ] ) {
62- select . value = pathStorage [ field . id ] ;
62+ if ( Array . isArray ( pathStorage [ field . id ] ) && select . multiple ) {
63+ Array . from ( select . options ) . forEach ( option => {
64+ option . selected = pathStorage [ field . id ] . includes ( option . value ) ;
65+ } ) ;
66+ } else {
67+ select . value = pathStorage [ field . id ] ;
68+ } ;
6369 } ;
6470 } ) ;
6571 } ) ;
@@ -104,6 +110,10 @@ window.onload = function () {
104110 radio . checked = true ;
105111 } ;
106112 } ) ;
113+ } else if ( ( input . tagName . toLowerCase ( ) === 'select' ) && input . multiple && Array . isArray ( restore [ key ] ) ) {
114+ Array . from ( input . options ) . forEach ( option => {
115+ option . selected = restore [ key ] . includes ( option . value ) ;
116+ } ) ;
107117 } else {
108118 input . value = restore [ key ] ;
109119 } ;
@@ -294,6 +304,8 @@ async function create() {
294304 radios . forEach ( radio => {
295305 if ( radio . checked ) data [ field . id ] = radio . value ;
296306 } ) ;
307+ } else if ( ( input . tagName . toLowerCase ( ) === 'select' ) && input . multiple ) {
308+ data [ field . id ] = Array . from ( input . selectedOptions ) . map ( option => option . value ) ;
297309 } else {
298310 data [ field . id ] = input . value ;
299311 } ;
@@ -373,6 +385,8 @@ async function save() {
373385 radios . forEach ( radio => {
374386 if ( radio . checked ) data [ field . id ] = radio . value ;
375387 } ) ;
388+ } else if ( ( input . tagName . toLowerCase ( ) === 'select' ) && input . multiple ) {
389+ data [ field . id ] = Array . from ( input . selectedOptions ) . map ( option => option . value ) ;
376390 } else {
377391 data [ field . id ] = input . value ;
378392 } ;
0 commit comments