2

I have an array like the following.

$form["something"]["something"] = array(
  0 => array( "#markup" => "line 0" ),
  1 => array( "#markup" => "line 1" ),
  2 => array( "#markup" => "line 2" ),
);

When rendering it in the theme function with drupal_render($form["something"]["something"]), I get only the first line.

line 0

When I try to use foreach, this somehow does not return anything.

So what am I doing wrong? Should I modify an array itself and add some wrapper element? I would prefer to render it all with one line, without foreach.

6

Instead of drupal_render(), you should use drupal_render_children().

print drupal_render_children($form["something"]["something"]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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