Hey @populist,

I was wondering if it is possible to get the preview functionality to work with the panels_edit_style_settings_form

Right now the preview works for:

a) _content_type_edit_form
b) panels_edit_style_type_form

Comments

populist’s picture

Assigned: Unassigned » beeradb

Delegated!

beeradb’s picture

@sylus: any chance you can direct me to the easiest way to find this form? Is this for panels styles which have configurable options?

populist’s picture

Status: Active » Needs review
StatusFileSize
new2.01 KB

@sylus: my guess this is going to work exactly the same way to the initial style form. here is a patch that extends panopoly_magic's magic. give it a test!

populist’s picture

Status: Needs review » Fixed

I went ahead and pushed this out. Give the latest -dev a review to make sure it works for you.

sylus’s picture

Thanks for taking a look at this @populist unfortunately it is still not showing up for me, I'll take a further look tomorrow to make sure not something I did wrong :)

populist’s picture

Status: Fixed » Needs work
sylus’s picture

I tested it further out and looks like something must still be missing for this to fire. All of the functions in the patch were run though.

An example of my settings form for one of my panes is as follows:


// Plugin definition
$plugin = array(
  'title' => t('Tabbed Interface'),
  'description' => t('Display the pane with customized settings for the Tabbed Interface Plugin.'),
  'render pane' => 'wetkit_widgets_tabbed_interface_style_render_pane',
  'pane settings form' => 'wetkit_widgets_tabbed_interface_style_settings_form',
  'weight' => -5,
);

/**
 * Settings Form.
 */
function wetkit_widgets_tabbed_interface_style_settings_form($style_settings) {

  $form['tabbed_interface_classes'] = array(
    '#type' => 'select',
    '#title' => t('Class'),
    '#options' => array(
      '' => t('Empty'),
      'tabs-style-1 auto-play cycle' => t('Style 1'),
      'tabs-style-2 auto-play cycle' => t('Style 2'),
      'tabs-style-3 auto-play cycle' => t('Style 3'),
      'tabs-style-4 auto-play cycle' => t('Style 4'),
      'tabs-style-5 auto-play cycle' => t('Style 5'),
      'tabs-style-7 auto-play animate-slow cycle' => t('Style 7'),
    ),
    '#default_value' => (isset($style_settings['tabbed_interface_classes'])) ? $style_settings['tabbed_interface_classes'] : '',
  );

  return $form;
}
beeradb’s picture

Status: Needs work » Needs review
StatusFileSize
new742 bytes

@sylus: give this one a try? it fixes the issue for me on my local.

populist’s picture

Status: Needs review » Fixed

I checked this out and looks good too. Rolling it into -dev for further review.

sylus’s picture

Works for me :) Thanks so much!!!

sylus’s picture

Status: Fixed » Active
StatusFileSize
new127.67 KB

Hey :)

Really appreciate the work done on this so far but there is still a problem with this functionality.

While the preview does now work it does not take into account and breaks change in the settings form.

I have attached a picture. Basically when I change styles from 1-7 different classes get applied to my pane. With the new code addition these classes never get applied. Reverting the changes everything works again.

sylus’s picture

Category: feature » bug

Can still confirm this on latest dev, that none of the styles are being applied, setting in panopoly_magic_form_alter

$pane = $form_id == 'panels_edit_style_settings_form' ? $form_state['display']->content[$form_state['pid']] : $form_state['pane'] fixes the problem.

to

$pane = $form_id == $form_state['pane'] 

Fixes the problem but removes the preview.

sylus’s picture

I did notice that where we have the following statement again in wetkit_magic.module:

$style = ($form_state['rebuild'] && $form_id == 'panels_edit_style_settings_form') ? panels_get_style($form_state['values']['style']) : panels_get_style($form_state['style']);

That I think it should be:

$style = ($form_state['rebuild'] && $form_id == 'panels_edit_style_settings_form') ? panels_get_style($form_state['values']['settings']) : panels_get_style($form_state['style']);

Which despite the preview not updating the correct styles do now get passed.

populist’s picture

The problem here is that in panopoly_magic_form_alter() there is a section that determines the style for the pane as referenced in #13. At issue is on a settings form, the way the style plugin is passed is different. In the example from #7, the style is actually in $form_state['style'] directly and elsewhere it needs to be loaded. This just needs smarter handlng.

The cases we need to cover:

-- stylizer (across various use cases)
-- style plugins with settings (both when loaded for the first time and when auto submitted during preview)
-- style plugins without settings

beeradb’s picture

I've looked into this a fair bit as well, and there are actually 2 different issues at play. The outline in #14 are the steps needed to get preview working. A secondary issue is that once the "update preview" button is clicked (or auto submitted) the form no longer saves correctly. In fact the "tabbed interface" selection from step 1 even reverts to the first selection in the list.

This could potentially be tied to the $form_state['style'] wackiness described in #14, but I wanted to make sure it was documented here so when we fix this we make sure to knock out both items at once.

beeradb’s picture

Status: Active » Needs review
StatusFileSize
new4.63 KB

This ended up being a combination of several things. The behaviors listed in #14 and #15 were present, but layered on top of a panels form caching bug. This patch fixes the preview behavior, and there's a patch over at #1797298: Form caching cause references to break, preventing save of stylizer settings forms which fixes the panels bug.

Here's hoping this one is behind us :)

beeradb’s picture

StatusFileSize
new3.84 KB

Noticed a typo in the comments, attached patch fixes it.

beeradb’s picture

StatusFileSize
new4.64 KB

Ack. wrong patch. I really should clean up my patches directory so I don't have dozens to choose from.

This one fixes the typo.

populist’s picture

Status: Needs review » Fixed

I made a few updates to the patch in #18 to put the selection settings in a fieldset, but otherwise it looks good. I was doing my testing from the settings plugin that stylus provided as an example, but presumably this will need a bit more testing around all use cases. For now, however, this has been committed and pushed into -dev.

sylus’s picture

Can confirm this works though had to add the patch from panels that @beeradb made in: http://drupal.org/node/1797298

I can't say how much I appreciate you guys taking the effort to solve this! Much obliged :)

populist’s picture

Status: Fixed » Active

Lovely! I will make sure to get that patch rolled in the make file as well.

populist’s picture

Status: Active » Fixed

I pushed up this patch to Panopoly Core's makefile and updated the Panels issue to RTBC. Good to go!

Status: Fixed » Closed (fixed)

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