diff --git a/core/includes/common.inc b/core/includes/common.inc
index 19e0d59..f401d5f 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -5928,7 +5928,7 @@ function drupal_render(&$elements) {
   }
 
   // Get the children of the element, sorted by weight.
-  $children = element_children($elements, TRUE);
+  $children = element_children($elements, TRUE, TRUE);
 
   // Initialize this element's #children, unless a #pre_render callback already
   // preset #children.
@@ -6480,11 +6480,13 @@ function element_child($key) {
  *   The element array whose children are to be identified.
  * @param $sort
  *   Boolean to indicate whether the children should be sorted by weight.
+ * @param $allow_arrayaccess_objects
+ *   Internal parameter intended for render API only. Do not use.
  *
  * @return
  *   The array keys of the element's children.
  */
-function element_children(&$elements, $sort = FALSE) {
+function element_children(&$elements, $sort = FALSE, $allow_arrayaccess_objects = FALSE) {
   // Do not attempt to sort elements which have already been sorted.
   $sort = isset($elements['#sorted']) ? !$elements['#sorted'] : $sort;
 
@@ -6493,7 +6495,11 @@ function element_children(&$elements, $sort = FALSE) {
   $sortable = FALSE;
   foreach ($elements as $key => $value) {
     if ($key === '' || $key[0] !== '#') {
-      if (is_array($value)) {
+      // We want to allow objects implementing ArrayAccess in render API but
+      // not in form API and our forms can contain renderables so return
+      // these only for render API but not form API.
+      $array_access = $value instanceOf ArrayAccess;
+      if (is_array($value) || ($allow_arrayaccess_objects && $array_access)) {
         $children[$key] = $value;
         if (isset($value['#weight'])) {
           $sortable = TRUE;
@@ -6501,7 +6507,7 @@ function element_children(&$elements, $sort = FALSE) {
       }
       // Only trigger an error if the value is not null.
       // @see http://drupal.org/node/1283892
-      elseif (isset($value)) {
+      elseif (isset($value) && !$array_access) {
         trigger_error(t('"@key" is an invalid render array key', array('@key' => $key)), E_USER_ERROR);
       }
     }
