8

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?

11

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.

3
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

2

Use drupal_retrieve_form to get the structured form array:

$form_state = array();
dsm(drupal_retrieve_form('search_theme_form', &$form_state));

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.