This is very much related to http://drupal.org/node/90102.

I found another error with having a form rendered in the preview: it's not available in the DOM (tested in Firefox). This is because it's not allowed to have nested forms; validate a preview page and you will get an error. Firefox seems to deal with this by ignoring the child form. You can see this if you try to use css or javascript on the form tag.

Anyway, my point is that this isn't just a problem with Opera (see the above issue), but a bug in our rendered markup.

If we want to render the form when previewing I suggest that we render a "dummy" form, e.g by replacing the form tags with div tags when rendering a form in preview. It will still be invalid markup but might solve the Opera bug and feature CSS and javascript issues...

...or we could render the result view as poll.module does.

Comments

anders.fajerson’s picture

On second thoughts, the main problem is not that we render a form in the preview, the problem is that Drupal renders the preview HTML within the node_form. So the best solution is probably not what I suggested above, instead this should be taken care of in core: that is to render the preview above the node_form and not within as it is done now.

Function theme_node_form() is a good start. I don't know enough about form rendering to say if this can be solved within that theme function, that would really simplify things.

ChrisKennedy’s picture

Unfortunately I've hardly used the theming functionality of drupal. Your'e right that theme_node_form() is where the preview is being displayed but it appears that the initial form tag is output somewhere earlier.

If we need to temporarily switch to displaying results in the preview that's fine, but in the long run I think displaying the ballot is the most intuitive.

ChrisKennedy’s picture

Good job figuring out the cause of this bug btw.

anders.fajerson’s picture

Suggested battle plan:
*temporary swith to render result
* file a feature request (bug?) against Drupal 6 (I don't think we can get this in in Drupal 5, especially if we can't offer an easy solution by ouselves, I failed at least)

anders.fajerson’s picture

Talked with chx in #drupal and it's indeed a bug. And there seems to be an easy solution, #prefix, can't believe I didn't thought of it :)

If nothing else comes up, this will be taken care of already in Drupal 5.

anders.fajerson’s picture

Status: Active » Closed (won't fix)
ChrisKennedy’s picture

Sounds good - http://drupal.org/node/100775 is the issue for future reference.

ChrisKennedy’s picture

Version: master » 5.x-1.x-dev

This just got fixed in core, so it should be working now.

http://drupal.org/node/100775
http://drupal.org/node/100787