I ended up using a workaround to solve this problem. Instead of attempting to store a multidimensional array as described above, I instead store a simple array of values created by combining the type with the id.
So, instead of:
array(
[0] => ( 'id' => 1, 'type' => 'location', 'name' => 'University Library'),
[1] => ( 'id' => 7, 'type' => 'service', 'name' => 'Circulation Desk') );
The array becomes:
array( 'L1', 'S7' );
For the list items, I nested a hidden input inside the list item that will has the name attached and the value I want to store, like so:
<?php
foreach( $instance['order'] as $order ) :
if( $order ) : ?>
<li value="<?php echo $order ?>">
<span> Library name. </span>
<input
type="hidden"
name="<?php echo $this->get_field_name( "order' ) ?>[]'
value="<?php echo $order ?>"
/>
<a class="destroy_parent">X</a>
</li>
<?php
endif;
endforeach; ?>
Notice the input
‘s name and it’s value. The []
at the end of the name indicates that an array of values will be stored.