• Hi Greg,

    First of all, thank you for taking the time to create this plugin, it’s saved me a LOT of time… Well almost anyway 😉

    After 3-4 hours I realised that the WP_Widget::Form method isn’t used to pre-populate the form when editing an already saved widget.

    For most users, this isn’t an issue, however for me, I need to pre-populate content based on arrays which your panelsCreatePanel method does not handle.

    As a way around this, I’ve decided to modify your code a little, which is going to break the next time you update yours 🙁

    Could you possibly look into an official implementation of the following piece of code?

    if ( data != undefined ) {
        // Get the widget type and attempt to execute
        // a callback function should it exist.
        var type = data['info'].class,
            callback = 'panels_' + type + '_populate';
        if (typeof window[callback] === 'function') {
            window[callback].call(dialog, data);
        }
        // Populate the form values
        for ( c in data ) {
            if ( c != 'info' ) {
                var de = dialog.find( '*[name$="[' + c + ']"]' );
    
                if ( de.attr( 'type' ) == 'checkbox' ) {
                    de.prop( 'checked', Boolean( data[c] ) );
                }
                else {
                    de.val( data[c] );
                }
            }
        }
    }

    For example, if I had a Widget called Test, I would create a function named panels_Test_populate which would accept the dialog as the context and the data variable as the parameter.

    This would then allow your users to loop through any content and populate it where it hasn’t already been done using your existing method.

    I’d be interested in hearing back from you on your or anyone elses thoughts on this.

    Many thanks

    Gavin

    http://wordpress.org/plugins/siteorigin-panels/

Viewing 1 replies (of 1 total)
  • My take on this is that it would be better served to rewrite the code to function similarly to the native widgets screen. That would reduce a lot of compatibility issues and widget developers won’t have to write special workaround code to get their widgets working.

Viewing 1 replies (of 1 total)
  • The topic ‘Suggestion: Editing a widget after updating (advanced)’ is closed to new replies.