By nathanatvscreen on
I am trying to render a webform in code. I have the following:
$node = node_load(10971);
$submission = (object) array();
$enabled = TRUE;
$preview = FALSE;
$form = drupal_get_form('webform_client_form_10971', $node, $submission, $enabled, $preview);
drupal_render($form);
If I print_r the contents of $form, I see that my form is there in the array. But when I call drupal_render on it, the form doesn't appear on the page. I don't get an error or anything else that would tell me what is going wrong.
Any ideas?
Thanks,
Nathan
Comments
More info
Having dug in to this a bit more, the form array doesn't seem to have an #access element. This is causing drupal_render to just return nothing. Why would my webform array not have the #access element?
It doesn't need to. The
It doesn't need to. The absence of an #access element means access is granted.
Try calling render() instead of drupal_render().
Contact me to contract me for D7 -> D10/11 migrations.
Tried that; same result.
Tried that; same result.
Are you actually doing
Are you actually doing anything with that rendered form? And what is the context of this code? Where is it? How are you using it? Is this the complete code? etc.
Contact me to contract me for D7 -> D10/11 migrations.
Don't forget to actually
Don't forget to actually print out the renderable array:
Thank you. I wasn't printing
Thank you. I wasn't printing it.
print drupal_render($form); solved it.