In Drupal 7, if you return output of drupal_get_from() directly it works, but not assigned to a variable.

For instance,

function mymodule_admin_config_page($extra = NULL) {
  return drupal_get_form('mymodule_admin_config_form', $extra);
}

is working, but not

function mymodule_admin_config_page($extra = NULL) {
  $content = "Some static content";
  $content .=   drupal_get_form('mymodule_admin_config_form', $extra);
  return $content;
}

which returns string "Array" as output(when I print_r($content); exit;, got the same "Array" string).

It is working fine in Drupal 6 and I'm trying to covert to D7.

any idea? or is this intended change and have any documentation to refer?

Thank you in advance!!!

Comments

venkatd’s picture

I am having the same issue. I am not sure why, but drupal_get_form seems to be returning the $form configuration array whenever I call it.

Now I call something like:

$form = drupal_get_form('my_form_name');
$html = drupal_render($form);
//now use the rendered form wherever you please

and it is working for me. Again, I don't know the reason for this behavior.