开发者

Iteratively list Drupal form titles

I am trying to list all #titles in a Drupal form module; however, I can't seem to get it to work.

foreach ($form_values as $key => $value) {
   echo $form['myForm'][$key]['#title'];
}

The method above does not return anything. I can list the $key values by doing the following:

foreach (...) {
   echo $key .开发者_如何学运维 ' ';
}

but I can't find a way to list the titles (e.g., '#title' => t('Name')) for each form input.

Any help? Thanks!


Your request a bit baffles me, but

function print_title($form) {
  foreach (element_children($form) as $key) {
    print_title($form[$key]);
  }
  if (isset($form['#title'])) {
    // do something with your title
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜