duanfeiqu1989 2017-02-16 18:44 采纳率: 100%
浏览 37

Drupal webform中的数组到字符串转换

Before upgrading from Webfrom 7.3 to 7.4, this code used to work

 $html = $html . webform_submission_render($node, $submission, NULL, 'html');

My HTML would display and then the HTML from the submission would follow.

Now, it returns a page displaying the contents of $html and then prints Array after. Drupal gives me a "Notice: Array to string conversion". This is the HTML from that section on the page:

...16:16:22(/p)(/div)(br/)(br/)Array (/div)

If I exclude the function and just leave the $html:

$html = $html

all the HTML is displayed correctly.

If I exclude the $html and just leave the function:

$html = webform_submission_render($node, $submission, NULL, 'html');

the submission is displayed correctly on the page, in HTML. I then used dpm:

dpm(webform_submission_render($node, $submission, NULL, 'html') );

and it, in fact, returns ...(Array, 15 elements)

How do I get the array to actually convert to html before appending to the rest of the $html?

  • 写回答

1条回答 默认 最新

  • doqo89924 2017-02-17 04:19
    关注

    This is most likely a bug in Webform 7.4. The webform_submission_render() function was changed in 7.4, and doesn't pass $renderable through drupal_render() before returning. Inserting drupal_render() into the function as before returns the correct HTML. Alternatively, assigning the webform_submission_render() to a variable and then passing it through drupal_render() in the custom code produces the same result.

    $record = webform_submission_render($node, $submission, NULL, 'html');
    $html = $html . drupal_render($record);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?