I created a custom pane style (.inc plugin file). It does not include a 'render region' definition but a 'pane settings form' as described in #1178086-6: Custom pane style with a settings form.
When i select this style for a pane, click "next" but do *not* hit "save" at the second screen but close the popup instead.

After i hit "update&save" at panels configuration and checking region style setting it shows the pane style name which was never available to select for a region by intention.

The panel itself - when requested by the browser - throws
Notice: Undefined index: render region in panels_renderer_standard->render_region() (line 642 of /sites/all/modules/contrib/panels/plugins/display_renderers/panels_renderer_standard.class.php).

...and no pane is shown.

Do i have to define always a 'render region' as well?
Reproduced with plain drupal 7.26 and panels 7.x-3.4 and 7.x-3.x-dev.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rokr’s picture

Issue summary: View changes
rokr’s picture

To reproduce just put this file named 'issue.inc' at sites/all/modules/panels/plugins/styles


/**
 * @file
 * Definition of a collapsible panel pane.
 */

// Plugin definition
$plugin = array(
  'title' => t('Pane Style Issue #2238025'),
  'description' => t('Demonstrates Issue #2238025'),
  'render pane' => 'issue_style_render_pane',
  'pane settings form' => 'issue_settings_form',
);
/**
 * Render callback.
 *
 * @ingroup themeable
 */
function theme_issue_style_render_pane($vars) {
  // This makes no sense for rendering but enough to reproduce the issue
  return render($vars['content']->content);
}

/**
 * Settings form callback.
 */
function issue_settings_form($style_settings) {
  $form = array();
  $form['issue'] = array(
    '#type' => 'checkbox',
    '#title' => t('This is a checkbox. Do not hit save, but close this popup.'),
    '#default_value' => (isset($style_settings['issue'])) ? $style_settings['issue'] : FALSE
  );
  return $form;
}
jhedstrom’s picture

Seeing this as well. Looking into a solution.

jhedstrom’s picture

I've tracked this down to the panels cache that is maintained during editing. When a user skips out of a multi-step style settings form, the $this->cache->style is still set. That, combined with the logic in panels_renderer_editor::get_style() is what sets the style for regions to the style that was being configured for a pane:

  /**
   * Get the appropriate style from the panel in the cache.
   *
   * Since we have styles for regions, panes and the display itself, and
   * they are stored differently, we use this method to simplify getting
   * style information into a way that's easy to cope with.
   */
  function get_style($type, $pid = '') {
    if (isset($this->cache->style)) {
      $style = panels_get_style($this->cache->style);
      $defaults = isset($style['defaults']) ? $style['defaults'] : array();
      // Get the &$conf variable based upon whose style we're editing.
      switch ($type) {
        case 'display':
          $this->display->panel_settings['style'] = $this->cache->style;
          $this->display->panel_settings['style_settings']['default'] = $defaults;
          break;

        case 'region':
          $this->display->panel_settings[$pid]['style'] = $this->cache->style;
          $this->display->panel_settings['style_settings'][$pid] = $defaults;
          break;

        case 'pane':
          $pane = &$this->display->content[$pid];
          $pane->style['style'] = $this->cache->style;
          $pane->style['settings'] = $defaults;
          $conf = &$pane->style['settings'];
          break;
      }
    }

The issue is the if (isset($this->cache->style)) { logic doesn't care that it might be set for a pane.

I think the fix here is to allow the style cache to be unset when a user clicks the close button on the modal without completing the form. I am unsure how to go about that bit.

jhedstrom’s picture

Status: Active » Needs review
FileSize
2.17 KB

Thanks to merlinofchaos and jappery in IRC, I was able to find a fix that binds the closing of the CTools modal to trigger a click on the cancel button. Note the cancel button did not yet exist, but this patch adds that as well.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Had the same scenario as described in op and couldn't figure out how to reproduce for quite a while. Once I stumbled across this issue, I'm able to reproduce the issue without issue.

And the patch in #5 solves it.

jhedstrom’s picture

Priority: Normal » Critical

Bumping priority up for visibility. When this issue happens, it hugely impacts the panel being edited, which I would say warrants a critical priority.

japerry’s picture

Status: Reviewed & tested by the community » Fixed

Looks good. Committed!

  • japerry committed c243b3d on 7.x-3.x authored by jhedstrom
    Issue #2238025 by jhedstrom: Setting custom pane style with settings...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.