diff --git a/panopoly_magic.module b/panopoly_magic.module index dad4528..ab008f3 100644 --- a/panopoly_magic.module +++ b/panopoly_magic.module @@ -258,35 +258,42 @@ function panopoly_magic_form_alter(&$form, &$form_state, $form_id) { // Run entity information through standard submission form if this is a new or updated object // Update the pane settngs with the VID afterwards if (!$form_state['entity']->reusable || $form_state['op'] != 'add' || $form_state['rebuild'] == TRUE) { - // Process the entity to create a preview. Set the FPID to be the correct version. We need to - // generate a fake set of values to avoid notices from FPP as per http://drupal.org/node/1791734. - $default_values = array( - 'language' => '', - 'title' => '', - 'link' => '', - 'path' => '', - 'reusable' => '', - 'category' => '', - 'admin_title' => '', - 'admin_description' => '', - 'revision' => '', - ); - - if (!empty($form_state['values'])) { - $form_state['values'] = array_merge($default_values, $form_state['values']); - } - else { - $form_state['values'] = $default_values; + // Process the entity to create a preview. + + // + // This code is copied from fieldable_panels_panes_entity_edit_form_submit(): + // + + $entity = $form_state['entity']; + + // Copy hardcoded fields. + $entity->title = $form_state['values']['title']; + $entity->link = $form_state['values']['link']; + $entity->path = $form_state['values']['path']; + $entity->language = $form_state['values']['language']; + $entity->reusable = $form_state['values']['reusable']; + $entity->category = $form_state['values']['category']; + $entity->admin_title = $form_state['values']['admin_title']; + $entity->admin_description = $form_state['values']['admin_description']; + + $entity->revision = $form_state['values']['revision']; + // Only set a log message if there was a new revision. This prevents + // overwriting a log message on the current revision + if ($entity->revision) { + $entity->log = $form_state['values']['log']; } - // Attach fields in the form state so they can be rendered in preview. - field_attach_submit('fieldable_panels_pane', $form_state['entity'], $form, $form_state); + field_attach_submit('fieldable_panels_pane', $entity, $form, $form_state); + + // + // End code copied from fieldable_panels_panes_entity_edit_form_submit(). + // // Define the content type plugin to use for rendering the preview. $preview_type = 'fieldable_panels_pane_preview'; // Stash the entity stub for the preview content type. - $pane->configuration['fieldable_panels_pane'] = $form_state['entity']; + $pane->configuration['fieldable_panels_pane'] = $entity; } } diff --git a/plugins/content_types/fieldable_panels_pane_preview.inc b/plugins/content_types/fieldable_panels_pane_preview.inc index 6228c67..a6e8ac5 100644 --- a/plugins/content_types/fieldable_panels_pane_preview.inc +++ b/plugins/content_types/fieldable_panels_pane_preview.inc @@ -1,29 +1,24 @@ t('Fielded custom content (preview)'), - 'no title override' => TRUE, - 'description' => t('Preview for created custom panels pane with fields'), - 'category' => t('Fielded panes'), - 'all contexts' => TRUE, - 'defaults' => array( - 'view_mode' => 'full', - ), - ); -} +$plugin = array( + 'title' => t('Fielded custom content (preview)'), + 'no title override' => TRUE, + 'description' => t('Preview for created custom panels pane with fields'), + 'category' => t('Fielded panes'), + 'all contexts' => TRUE, + 'defaults' => array( + 'view_mode' => 'full', + ), +); /** * Callback to render our content type preview. @@ -35,7 +30,7 @@ function panopoly_magic_fieldable_panels_pane_preview_ctools_content_types() { function panopoly_magic_fieldable_panels_pane_preview_content_type_render($subtype, $conf, $panel_args = array(), $context = array()) { $entity = $conf['fieldable_panels_pane']; $view_mode = isset($conf['view_mode']) ? $conf['view_mode'] : 'full'; - if ($entity && !empty($entity->fpid) && fieldable_panels_panes_access('view', $entity)) { + if ($entity && fieldable_panels_panes_access('view', $entity)) { $settings = field_bundle_settings('fieldable_panels_pane', $entity->bundle); $block = new stdClass(); $block->title = '';