Form elements of type #markup (the default type) are allowed to have a title and a description, according to http://api.drupal.org/api/HEAD/file/developer/topics/forms_api_reference.... But these attributes are not outputted by theme_markup(), because it does not have the standard call to theme('form_element').

Attached patch fixes this.

CommentFileSizeAuthor
#2 theme_markup_1.patch655 bytesJaza
#1 theme_markup_0.patch582 bytesJaza
theme_markup.patch599 bytesJaza

Comments

Jaza’s picture

StatusFileSize
new582 bytes

Removed #id parameter from call to theme('form_element'), as this doesn't apply for #markup.

Jaza’s picture

StatusFileSize
new655 bytes

Updated to only call theme('form_element') if #title or #description are set, because calling it for existing #markup elements in core seems to wreck the layout of some pages (e.g. admin/modules).

killes@www.drop.org’s picture

Status: Reviewed & tested by the community » Needs review

This needs a review by some form API person.

Jaza’s picture

Title: theme_markup() should call theme('form_element') » Markup elements should not have title or description
Status: Needs review » Active

I have talked to chx, and it has been determined that markup elements should never be passed through theme('form_element'), as this wraps the element in a <div class="form-item">, which should never happen for markup.

The conclusion is that when a title and/or a description is needed, use type item instead of type markup. Title and description should no longer be allowed for elements of type markup. I couldn't see anywhere in the code that the rules of allowed attributes for form element types is defined, so it looks like it's just the docs on api.drupal.org that need to be updated.

Jaza’s picture

Project: Drupal core » Documentation
Component: forms system » Documentation in CVS
xano’s picture

Version: x.y.z »
Status: Active » Closed (fixed)