In a standard page load, each form that is built calls drupal_html_id() to get an unique form id across the entire page load. However, in the case of the IPE, there is a fair bit of form rebuilding that does not require a page load. As a result, a situation arises where a single form on the page (for example, #search-form) begins to change its ID each time the IPE is invoked (becoming #search-form--2 and then #search-form--3 and so on). This breaks various CSS assumptions (i.e. Bartik's theming of #search-form) and plenty of JS targeting.

This patch resets the $_POST['ajax_html_ids'] array upon saving the IPE which solves the problem of duplicate IDs since when drupal_html_id() inspects it upon rebuilding it can correctly generate the right and assumed ID. I am not sure if this is the right way to invalidate this, but wanted to open an issue with a patch to consider resolutions.

Comments

populist’s picture

StatusFileSize
new879 bytes

Here is a slight update that moves the html clearing a little higher up in the load order to make sure the ids get reset properly.

populist’s picture

StatusFileSize
new1.33 KB

And one more that also includes the case of changing layouts (as well as customizing the page) in the IPE.

populist’s picture

StatusFileSize
new856 bytes

Here is an update to keep with the -dev magic. .

UPDATE - PLEASE IGNORE PATCH 4. That was done against the Drupal 6 branch and, as we know, D6 is the past!

merlinofchaos’s picture

Status:Needs review» Fixed

Committed and pushed.

Status:Fixed» Closed (fixed)

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

  • Commit 3f50718 on 7.x-3.x, 7.x-3.x-i18n, 8.x-3.x by merlinofchaos:
    Issue #1555352 by populist: Preserve HTML ids on forms inside IPE when...