I want to use the dsm()
function of the Devel module to print the $form
array of a form, where the form_id
is search_theme_form
. How to do that?
3 Answers
Start a custom module, insert this code:
/**
* Implements hook_form_alter().
*/
function foo_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'search_theme_form') {
dpm($form);
}
}
Also, you might want to use dpm() over dsm() since the latter is a legacy function.
-
1@sokratis you can also download my simple module for forms developping - it adds the
dpm($form_state)
even after submitting– mojzisCommented Oct 12, 2012 at 18:04 -
function THEME_form_search_theme_form_alter (&$form, &$form_state){
krumo ($form); // you can use DSM as well here
}
Replace THEME with your theme name and put that in your template.php, if you want to do that from a module then replace THEME by your module name and put that funciton in your .module file
Use drupal_retrieve_form to get the structured form array:
$form_state = array();
dsm(drupal_retrieve_form('search_theme_form', &$form_state));