Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
I want to render the submissions of the current user on his page.
For this, I uses this code
<?php
$nid = 41;
$sid = 42;
$node = node_load($nid);
include_once drupal_get_path('module','webform') . '/includes/webform.submissions.inc';
$submission = webform_get_submission($nid, $sid);
$email = NULL;
$format = "html";
print webform_submission_render($node, $submission, $email, $format);
?>
But I get an empty array.
However with a print_r($submission) I get an array with the datas of the current user submission. The "webform_submission_render" function don't work...
Have you any idea to resolve my problem ?
Thanks for your help.
Comments
Comment #2
kumkum29 CreditAttribution: kumkum29 commentedHello,
after several tests, the function ("webform_submission_render") seems to be correct. But on the user page I get an error : "EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids()".
If I place this code in a node or page template, the results of the submission in html are rendered.
If I place this code in the page--user.tpl.php or in user-profile template, the page is broken and I get the above error.
After using devel & the backtrace function, it appears that the called arg in the last functions is "node". On the user page the argument is "user". Does the problem comes from this bad arg?
Is there a solution to resolve this problem ? Is there another solution to render a submission ?
Thanks for your help.
Comment #3
kumkum29 CreditAttribution: kumkum29 commentedComment #4
kumkum29 CreditAttribution: kumkum29 commentedComment #5
kumkum29 CreditAttribution: kumkum29 commentedComment #6
kumkum29 CreditAttribution: kumkum29 commentedI have found the solution.
In a specific component I have developped a custom behavior (conditions on the component). But I had problems in the code of my function. Then, I get the "EntityMalformedException:" message.
Now, it's resolved.