Title: $instance dosn&#039;t retrieve saved data
Last modified: August 21, 2016

---

# $instance dosn't retrieve saved data

 *  [masteryo](https://wordpress.org/support/users/masteryo/)
 * (@masteryo)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/)
 * Hello , I’m planning to develop many widgets to work with your builder
 * But I found a bug !
 * in siteorigin-panels/widgets/widgets.php on line 149 “public function form($instance){“
 * $instance should retrieve saved data but it’s empty cause you are saving widget’s
   settings as post meta “update_post_meta($post_id, ‘panels_data’, $panels_data);”
 * is there any work around ???
 * [http://wordpress.org/plugins/siteorigin-panels/](http://wordpress.org/plugins/siteorigin-panels/)

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/page/2/?output_format=md)

 *  Plugin Author [Greg – SiteOrigin](https://wordpress.org/support/users/gpriday/)
 * (@gpriday)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132061)
 * Hi masteryo!
 * Thanks for letting me know about this issue. I’m going to take a look at it as
   soon as I get back to the office.
 *  Thread Starter [masteryo](https://wordpress.org/support/users/masteryo/)
 * (@masteryo)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132062)
 * it’s possible to retrieve data in form function , but we need panel id to do 
   that
    like this :
 *     ```
       $global $post
       $all_instances = get_post_meta($post->ID, 'panels_data', true);
       foreach($all_instances $as $i => $instances)
           if($this->panel_id == $i)
              $instance = $instances;
       ```
   
 * unfortunately , you are creating panel id in panels.admin.panels.js , so it’s
   hard to get panel id in php
    `formHtml = formHtml.replace( /\{\$id\}/g, newPanelId);`
 *  Thread Starter [masteryo](https://wordpress.org/support/users/masteryo/)
 * (@masteryo)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132067)
 * Btw , edit gallery In gallery widget is not working
 * error in firebug :
    ReferenceError: event is not defined event.preventDefault();
   panels.admin.media.js (line 83)
 * You forgot to add event in ” click: function(){“
    click: function(event){
 *  Thread Starter [masteryo](https://wordpress.org/support/users/masteryo/)
 * (@masteryo)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132099)
 * Another Bug Found:
    if we enable “Copy Content to Post Content” I get always 
   php timeout
 *     ```
       // Update the post, removing this action first so we don't infinite loop.
               remove_action('save_post', 'siteorigin_panels_save_post');
               wp_update_post($post);
               add_action('save_post', 'siteorigin_panels_save_post', 10, 2);
       ```
   
 * I the above code didn’t fix stopping from infinite loop. If i remove it will 
   work fine
 *  Plugin Author [Greg – SiteOrigin](https://wordpress.org/support/users/gpriday/)
 * (@gpriday)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132161)
 * Your official title is now Bug Finder Extraordinaire 🙂
 * I’ll go over all these issues and fix up what I can. Most of the issues seem 
   fixable.
 *  Thread Starter [masteryo](https://wordpress.org/support/users/masteryo/)
 * (@masteryo)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132165)
 * 🙂 , thanks
 * Please let me know once you fix the issue especially the first bug , Cause I’m
   not able to continue develop widgets without fixing it
 *  Plugin Author [Greg – SiteOrigin](https://wordpress.org/support/users/gpriday/)
 * (@gpriday)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132266)
 * Just letting you know I haven’t forgotten about this thread. I’ve been really
   busy with a new theme launch. I’ll be getting to these issues soon.
 *  Thread Starter [masteryo](https://wordpress.org/support/users/masteryo/)
 * (@masteryo)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132279)
 * actually I’v been checking your page builder plugin in github every day looking
   for updates ,Really thank you for your great support
 * Don’t forget Please , let me know once you fix it
 *  Plugin Author [Greg – SiteOrigin](https://wordpress.org/support/users/gpriday/)
 * (@gpriday)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132283)
 * Is Page Builder on GitHub? I haven’t put it on myself, but due to popular demand,
   I’ll probably move development there as soon as I find some time.
 *  Thread Starter [masteryo](https://wordpress.org/support/users/masteryo/)
 * (@masteryo)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132284)
 * Huh? he is using your name that’s why I thought is you
    check it out [https://github.com/wp-plugins/siteorigin-panels](https://github.com/wp-plugins/siteorigin-panels)
 *  Plugin Author [Greg – SiteOrigin](https://wordpress.org/support/users/gpriday/)
 * (@gpriday)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132285)
 * That looks like something by Plugin Mirror that automatically syncs my updates
   from WP.org to GitHub. That’s pretty cool.
 * [http://www.pluginmirror.com/plugins/siteorigin-panels/](http://www.pluginmirror.com/plugins/siteorigin-panels/)
 * It looks up to date, so you can keep an eye out for updates there.
 *  Thread Starter [masteryo](https://wordpress.org/support/users/masteryo/)
 * (@masteryo)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132299)
 * Dear Greg Priday, When do you think the first bug will be fixed?
 * Cause if it’s going to take time , I’ll try to figure out work around
 *  Thread Starter [masteryo](https://wordpress.org/support/users/masteryo/)
 * (@masteryo)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132301)
 * I was trying to figure out a solution , but I think the only solution is to retrieve
   data & widget form of opened dialog using ajax
 *  [Tenatious](https://wordpress.org/support/users/tenatious/)
 * (@tenatious)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132364)
 * Masteryo, would this explain why array data doesn’t show in the pagebuiler widget
   options but it does show on the site?
 *  [scottsawyer](https://wordpress.org/support/users/scottsawyer/)
 * (@scottsawyer)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/#post-4132365)
 * [@masteryo](https://wordpress.org/support/users/masteryo/), your code in [http://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data?replies=15#post-4655592](http://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data?replies=15#post-4655592)
   really helped me get close. Here is what I had to do to make this work for me.
 *     ```
       public function form ( $instance ) {
           if ( empty( $instance ) ) {
             global $post;
             $all_instances = get_post_meta( $post->ID, 'panels_data', true);
             foreach( $all_instances['widgets'] as $i => $instances ) {
               if ( $this->panel_id == $i ){
                 $instance = $instances;
               }
             }
           }
         /*
         awesome code for my custom widget
         */
       }
       ```
   
 * In my case, my widget has fields that are loaded dynamically are are used in 
   both the sidebar ( which already works fine ) and in the panels pages, so I just
   needed a condition for when the $instance is not available to the form function.
 * I am so happy now, thanks everyone!

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/page/2/?output_format=md)

The topic ‘$instance dosn't retrieve saved data’ 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/)

 * 17 replies
 * 5 participants
 * Last reply from: [Native Imaging](https://wordpress.org/support/users/native-imaging/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/instance-dosnt-retrieve-saved-data/page/2/#post-4132367)
 * Status: not resolved