I'm still getting to grips with render arrays and there similarity to FAPI arrays is a point of confusion. I'm customizing a node form using hook_form_alter and I wanted to insert some custom markup in place of a field.

I have inserted a table render array as a child of a the field FAPI container array and much to my surprise the table was rendered. What's going on here?

How do I know when a render array will be processed properly?

1 Answer 1


See Render Arrays in Drupal 7

Note: While render arrays and arrays used by the Form API share elements, properties and structure, many properties on form elements only have meaning for the Form API, not for the Render API. Form API arrays are transformed into Render arrays by drupal_get_form.

Because form arrays are converted to render arrays before they are rendered if you add a render array to the form array it will be also rendered when the whole form-array-converted-to-render-array is processed.

As the quoted text says you have to keep in mind that form arrays are not directly renderable, they have to be converted first to a render array. During this conversion, render array attached to the form array are bypassed because they are already a render array.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.