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
}
}
精彩评论