By ssiruguri on
I've been having trouble getting print_r/dvr/dsm print to the screen when I call these functions during the control flow inside drupal_get_form. Most recently, I tried calling it in my module's hook_form_alter, but got no output. However if I called:
<?php
function my_form_alter(&$form, $form_state, $form_id) {
return dvr($form);
}
?>
and then call print_r in drupal_alter(), it works fine and I see what it is that was passed into my hook.
I tried searching for an answer but haven't yet found one. Any help would be appreciated, as it will help me speed up debugging.
sameer.
Comments
Ach. I meant to type, in the
Ach. I meant to type, in the sample code:
First of all,
First of all, hook_form_alter() does not expect anything to be returned, so you're essentially returning the result of dvr() to nothing.
Drupal does crazy things in the background, so quite often anything output by certain functions does not display. This is why it's handy to put exit(); right after the print_r() statement to halt execution of the code.
I usually add this to the bottom of every module/theme I write:
... gets to be quite handy :).
If you don't want to use exit(), you can do something like this:
---
Yuriy Babenko
www.yubastudios.com
My Drupal tutorials: http://yubastudios.com/blog/tag/tutorials
---
Yuriy Babenko | Technical Consultant & Senior Developer
http://yuriybabenko.com