what is the difference between render() and drupal_render() anyway ? Is there a reason to use only drupal_render()?

1 Answer 1


The docs for render() explain it pretty well:

This function renders an element using drupal_render(). The top level element is shown with show() before rendering, so it will always be rendered even if hide() had been previously used on it.

render() is basically just a wrapper for drupal_render(), except that it makes sure the element passed in is set to be shown when passed through to drupal_render().

It also makes sure the element passed in is an array (which is all drupal_render() can accept). If it isn't, the element is return back as-is. So it provides a bit of a safety net if you like.

If for any reason you have a variable you need to render, and you don't know if it's a string or a render array, you can pass it straight through render() without having to test the variable type yourself.

For some real-world examples of that sort of situation there's a list of calls to render() you can look through.

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.