First off, I think this is a bug in ctools (since it's related to the form handling), but might also be in Panels. Feel free to move the issue if I messed up which project it is.

I've overriden the node/edit page with Page Manager, add the "node being edited" base form to the content (Add -> Form -> General Form -> node being edited). When I visit node/add/page (or any other node type), or node/NID/edit, I see two identical form open tags immediately following each other. This is invalid HTML, and I think it's the cause of a problem I'm experiencing with a View in this panel; when I submit the filter form for the view, it actually ends up submitting the node form.

Here's a dump of a simple variant that only renders the node form. If you load this and visit node/add/page, you'll see the form tag being rendered twice. (at least, I could reproduce it in a clean install with nothing enabled except page manager and panels)

$handler = new stdClass();
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
$handler->api_version = 1;
$handler->name = 'node_edit_panel_context';
$handler->task = 'node_edit';
$handler->subtask = '';
$handler->handler = 'panel_context';
$handler->weight = 0;
$handler->conf = array(
  'title' => 'Panel',
  'no_blocks' => 0,
  'pipeline' => 'standard',
  'body_classes_to_remove' => '',
  'body_classes_to_add' => '',
  'css_id' => '',
  'css' => '',
  'contexts' => array(),
  'relationships' => array(),
  'access' => array(
    'logic' => 'and',
  ),
);
$display = new panels_display();
$display->layout = 'onecol';
$display->layout_settings = array();
$display->panel_settings = array( 
  'style_settings' => array(
    'default' => NULL,
    'middle' => NULL,
  ),
);
$display->cache = array();
$display->title = '';
$display->content = array();
$display->panels = array();
  $pane = new stdClass();
  $pane->pid = 'new-1'; 
  $pane->panel = 'middle';
  $pane->type = 'form';
  $pane->subtype = 'form';
  $pane->shown = TRUE;
  $pane->access = array();
  $pane->configuration = array(
    'context' => 'argument_node_edit_1',
    'override_title' => 0,
    'override_title_text' => '',
  );
  $pane->cache = array();
  $pane->style = array(
    'settings' => NULL,
  );
  $pane->css = array();
  $pane->extras = array(); 
  $pane->position = 0;
  $pane->locks = array();
  $display->content['new-1'] = $pane;
  $display->panels['middle'][0] = 'new-1';
$display->hide_title = PANELS_TITLE_FIXED;
$display->title_pane = 'new-1';
$handler->conf['display'] = $display;

I was unable to find an immediately obvious cause of this bug; there are no templates that render the same thing twice. Any help in debugging this would be appreciated.

Comments

merlinofchaos’s picture

I'm confused. You can't place exposed filters inside a node edit form. That's a given.

merlinofchaos’s picture

So, checking on my dev site, you're right; something seems to have changed that is causing the form tag to be rendered twice. Most browsers seem to cope with this.

However, fixing this will not make an exposed filter form inside a node edit form work. HTML simply cannot accomplish that.

Peter Bex’s picture

I was under the impression that the actual form itself would be rendered by the "general form"/"node being edited" pane, not surrounding the entire page.

But no matter, the double form tag bug is still valid ;)

merlinofchaos’s picture

No, the entire panel is the form; that's what allows you to rearrange the form. Otherwise you'd really just have a single pane that you'd insert and be done with it.

Yes, the existence of the two form tags is invalid, which is why I didn't close the issue. However, browsers seem to cope with it so I don't consider it a major bug, but it is a bug.

noslokire’s picture

Came across this as well, stopped us cold in our progress. We are hacking around it using jQuery but will hopefully tackle a long term solution as well tomorrow

RunePhilosof’s picture

@merlinofchaos Browsers can cope with it if it is reasonable to ignore all nested form elements on the page.

However, on my site I have a search form in my site_template (with panels_everywhere) and of course this search form doesn't work when it is nested inside the user edit or node edit form.

mikeytown2’s picture

Project: Chaos Tool Suite (ctools) » Panels
Version: 7.x-1.x-dev » 7.x-3.x-dev
Component: Page Manager » Code
Status: Active » Needs review
StatusFileSize
new973 bytes

I've identified that the issue is with the theme_panels_render_display_form function. I'm not sure how to fix this here so we have a core patch that does the job for us. Long story short the theme_form function is getting called twice for the same bit of information.

Debug Backtrace from theme_form when the same bit of information gets called twice. First time happens from theme_panels_render_display_form. Not sure why it get's called the second time.

Array (
    [0] => Array (
            [file] => /var/www/html/includes/theme.inc
            [line] => 1142
            [function] => theme_form
        )
    [1] => Array (
            [file] => /var/www/html/sites/all/modules/panels/panels.module
            [line] => 1092
            [function] => theme
        )
    [2] => Array (
            [file] => /var/www/html/includes/theme.inc
            [line] => 1142
            [function] => theme_panels_render_display_form
        )
    [3] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5842
            [function] => theme
        )
    [4] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5849
            [function] => drupal_render
        )
    [5] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5849
            [function] => drupal_render
        )
    [6] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5941
            [function] => drupal_render
        )
    [7] => Array (
            [file] => /var/www/html/sites/all/themes/datasphere/templates/page.tpl.php
            [line] => 65
            [function] => render
        )
    [8] => Array (
            [file] => /var/www/html/includes/theme.inc
            [line] => 1495
            [function] => include
        )
    [9] => Array (
            [file] => /var/www/html/includes/theme.inc
            [line] => 1185
            [function] => theme_render_template
        )
    [10] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5842
            [function] => theme
        )
    [11] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5704
            [function] => drupal_render
        )
    [12] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 2656
            [function] => drupal_render_page
        )
    [13] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 2544
            [function] => drupal_deliver_html_page
        )
    [14] => Array (
            [file] => /var/www/html/includes/menu.inc
            [line] => 532
            [function] => drupal_deliver_page
        )
    [15] => Array (
            [file] => /var/www/html/index.php
            [line] => 21
            [function] => menu_execute_active_handler
        )
)
Array (
    [0] => Array (
            [file] => /var/www/html/includes/theme.inc
            [line] => 1142
            [function] => theme_form
        )
    [1] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5857
            [function] => theme
        )
    [2] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5849
            [function] => drupal_render
        )
    [3] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5849
            [function] => drupal_render
        )
    [4] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5941
            [function] => drupal_render
        )
    [5] => Array (
            [file] => /var/www/html/sites/all/themes/datasphere/templates/page.tpl.php
            [line] => 65
            [function] => render
        )
    [6] => Array (
            [file] => /var/www/html/includes/theme.inc
            [line] => 1495
            [function] => include
        )
    [7] => Array (
            [file] => /var/www/html/includes/theme.inc
            [line] => 1185
            [function] => theme_render_template
        )
    [8] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5842
            [function] => theme
        )
    [9] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 5704
            [function] => drupal_render
        )
    [10] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 2656
            [function] => drupal_render_page
        )
    [11] => Array (
            [file] => /var/www/html/includes/common.inc
            [line] => 2544
            [function] => drupal_deliver_html_page
        )
    [12] => Array (
            [file] => /var/www/html/includes/menu.inc
            [line] => 532
            [function] => drupal_deliver_page
        )
    [13] => Array (
            [file] => /var/www/html/index.php
            [line] => 21
            [function] => menu_execute_active_handler
        )
)
mikeytown2’s picture

StatusFileSize
new953 bytes

updated patch against core. Previous one could still cause rendering errors in the browser.

merlinofchaos’s picture

The reason that form is happening twice is that it exists in #theme_wrappers. What I don't know is if it will *always* exist in theme wrappers, but I think we can rely on this behavior and be safe.

Try this patch, it won't require a core patch and I *think* it covers all our bases.

merlinofchaos’s picture

mikeytown2’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #10 fixes the issue! Thanks :)

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Fabulous, thanks for testing! Committed and pushed.

Status: Fixed » Closed (fixed)

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

  • Commit dc64a47 on 7.x-3.x, 7.x-3.x-i18n, 8.x-3.x by merlinofchaos:
    Issue #1649046: Fix double form rendering with all Panels form contexts.