In certain scenarios, form error messages are keyed by the element ID, rather than numerically.

In a Zen subtheme, this means that if there is only one error, it will not be displayed, and the following notice appears:

Notice: Undefined offset: 0 in zen_status_messages() (line 679 of /www/b2b/releases/20150623213042/profiles/b2bprofile/themes/zen/template.php).

This has happened due to some custom code in our site, but the issue doesn't occur in bartik.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

malcomio’s picture

Version: 7.x-5.5 » 7.x-5.x-dev
Status: Active » Needs review
FileSize
327 bytes
malcomio’s picture

Title: Single form error message not displayed if » Single form error message not displayed if keyed by element name
star-szr’s picture

Status: Needs review » Needs work
Related issues: +#1946240: Remove the hardcoded 0 index in theme_status_messages()

Thanks @malcomio! See this core issue: #1946240: Remove the hardcoded 0 index in theme_status_messages() (why it works in Bartik), reset() is more appropriate here.

malcomio’s picture

Status: Needs work » Needs review
FileSize
329 bytes

Thanks - here's the patch with reset instead of end

star-szr’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

  • JohnAlbin committed 808cda4 on 7.x-5.x authored by malcomio
    Issue #2516054 by malcomio: Single form error message not displayed if...

  • JohnAlbin committed 8a28454 on 7.x-6.x authored by malcomio
    Issue #2516054 by malcomio: Single form error message not displayed if...
JohnAlbin’s picture

Assigned: malcomio » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks, Malcolm!

  • JohnAlbin committed 808cda4 on 7.x-6.x authored by malcomio
    Issue #2516054 by malcomio: Single form error message not displayed if...

  • JohnAlbin committed 808cda4 on 8.x-7.x authored by malcomio
    Issue #2516054 by malcomio: Single form error message not displayed if...
  • JohnAlbin committed 8a28454 on 8.x-7.x authored by malcomio
    Issue #2516054 by malcomio: Single form error message not displayed if...

Status: Fixed » Closed (fixed)

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