Title: saving array fails
Last modified: August 21, 2016

---

# saving array fails

 *  [Michael](https://wordpress.org/support/users/ms-s/)
 * (@ms-s)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/saving-array-fails/)
 * Hi again,
 * I’d like to create some type of slider-widget. I know, there are plenty out there,
   but it seems none of them really is that convenient to use.
 * So I wanted to do create my own with the option of repeatable fields and a media
   uploader.
    After some time working I’ve come so one media uploader button and
   a multiple select field catching the images.
 * `<select multiple="multiple" name="<?php echo $this->get_field_name( 'sosuImages');?
   >[]" id="<?php echo $this->get_field_id( 'sosuImages' ); ?>" style="width:100%;"
   ></select>`
 * Saving goes like this:
 *     ```
       $instance['sosuImages'] = array();
       foreach ($new_instance['sosuImages'] as $img) {
       			$instance['sosuImages'][] = $img;
       		}
       ```
   
 * With jQuery I’ll get all option fields selected when the saving button is clicked,
   getting an array with all the option values.
 * Works gread using it in the theme widgets section, but breaks with ur plugin.
   
   Do you have any ideas why?
 * (this is the js btw)
 *     ```
       jQuery(document).on('click', "#sosuNivoUpload", function (){
   
       		tb_show('', 'media-upload.php?type=image&TB_iframe=true');
       		$('#TB_window').css('z-index', 1005);
       		widget_content = jQuery(this).parent();
   
       		window.send_to_editor = function(html) {
   
       			imgurl = jQuery('img',html).attr('src');
       			imgalt = (jQuery('img',html).attr('alt') != '') ? jQuery('img',html).attr('alt') : jQuery('img',html).attr('src');
   
       			var current = $("textarea[id*='sosunivowidget']").val();
   
       			$("select[id*='sosunivowidget']").append($('<option></option>').val(imgurl).html(imgalt));
       			$("textarea[id*='sosunivowidget']").val(current + imgurl + "\n");
   
       			tb_remove();
       			return false;
       		};
   
       	});
       ```
   
 * Cheers,
    Michael
 * [http://wordpress.org/extend/plugins/siteorigin-panels/](http://wordpress.org/extend/plugins/siteorigin-panels/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [scottsawyer](https://wordpress.org/support/users/scottsawyer/)
 * (@scottsawyer)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/saving-array-fails/#post-3843336)
 * I am having a similar issue, I suppose.
 * Have you attempted to print_r( $instance )? Even though my field values save,
   the $instance array is always set to default. I am pretty sure Page Builder uses
   it’s own mechanism for saving widget instance data. This is also a problem for
   me as I have several instances of the widget. Each time I edit the page, I must
   reset all of the instances.
 *  [Tenatious](https://wordpress.org/support/users/tenatious/)
 * (@tenatious)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/saving-array-fails/#post-3843339)
 * Did you get anywhere with this? I am also having the same issue where my widget
   works fine in the theme but not in the page builder!
 *  Thread Starter [Michael](https://wordpress.org/support/users/ms-s/)
 * (@ms-s)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/saving-array-fails/#post-3843340)
 * Sadly, no.
    I moved away from this plugin over to [http://wordpress.org/plugins/page-layout-builder/](http://wordpress.org/plugins/page-layout-builder/)
 * But mostly because of the bootstrap compatibily. So I didnt really looked for
   an answer to this topic anymore
 *  [Tenatious](https://wordpress.org/support/users/tenatious/)
 * (@tenatious)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/saving-array-fails/#post-3843341)
 * That’s a real shame. Is that plugin better would you say?
 *  Thread Starter [Michael](https://wordpress.org/support/users/ms-s/)
 * (@ms-s)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/saving-array-fails/#post-3843342)
 * not having too much trouble with it yet. As said, I like the bootstrap part of
   it, but I think its still bootstrap 2.x.
 * The first page builder plugin which uses bootstrap 3 gets my heart!
 *  [Tenatious](https://wordpress.org/support/users/tenatious/)
 * (@tenatious)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/saving-array-fails/#post-3843343)
 * It won’t let me disable the bootstrap CSS now I have selected it and it’s messing
   up my site :l

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘saving array fails’ is closed to new replies.

 * ![](https://ps.w.org/siteorigin-panels/assets/icon.svg?rev=2556869)
 * [Page Builder by SiteOrigin](https://wordpress.org/plugins/siteorigin-panels/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/siteorigin-panels/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/siteorigin-panels/)
 * [Active Topics](https://wordpress.org/support/plugin/siteorigin-panels/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/siteorigin-panels/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/siteorigin-panels/reviews/)

## Tags

 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [js](https://wordpress.org/support/topic-tag/js/)
 * [media](https://wordpress.org/support/topic-tag/media/)
 * [save](https://wordpress.org/support/topic-tag/save/)
 * [upload](https://wordpress.org/support/topic-tag/upload/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * 6 replies
 * 3 participants
 * Last reply from: [Tenatious](https://wordpress.org/support/users/tenatious/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/saving-array-fails/#post-3843343)
 * Status: not resolved