The FAPI docs say form elements' #theme property should be a string, but this property should be an array for *any* renderable element.

CommentFileSizeAuthor
#1 documentation_1818420_00.patch2.67 KBxano

Comments

xano’s picture

Status: Active » Needs review
StatusFileSize
new2.67 KB

Patch for Drupal 8 that fixes the documentation. Should work for Drupal 7 as well.

Status: Needs review » Needs work

The last submitted patch, documentation_1818420_00.patch, failed testing.

berdir’s picture

The change isn't correct either. It *can* be an array, but only because theme() also accepts an array. But this is a special case that is very seldomly used. Of 190 uses of "'#theme' in core, I've found exactly two that use an array.

so if anything, it should only documented that it is also possible to specify an array, maybe with a reference to the theme() documentation.

jhodgdon’s picture

Project: Drupal core » Documentation
Version: 8.x-dev »
Component: documentation » API documentation files
Issue tags: +FAPI reference

The FAPI reference is in the Documentation project repo

xano’s picture

Assigned: xano » Unassigned
avpaderno’s picture

Issue summary: View changes
Status: Needs work » Active
avpaderno’s picture

Title: #theme should be an array but is documented as a string » Document that #theme can be an array
Category: Bug report » Task

@Berdir is correct: The value for #theme is usually a string, but it could be an array too. It is not required to be an array.

I am not sure that needs to be documented, as there are few cases where an array is really necessary. (If an array were always expected, Drupal core would require an array by default.)

avpaderno’s picture

I checked the 8.x-1.x branch for this project repository, but it is empty. I take the documentation files are not on this project anymore.

quietone’s picture

Status: Active » Closed (won't fix)

This is for the Drupal 7 Form API reference. Since Drupal 7 is past end-of-life this is now a "won't fix".
Work on documentation for form elements for supported versions of Drupal is at #2486967: [meta] Move/Create Form Element Documentation and #3313535: [Meta] Improve documentation for Render and Form Elements.

avpaderno’s picture