TypeError in getCellRaw: string expected, Markup received

Created on 13 December 2024, about 1 month ago

Problem/Motivation

TypeError when showing webforms with a Twig element. Using the views_aggregate module, I want to display a table of webform submissions. That used to work with previous code - however, I cannot pinpoint which.

I am using views_aggregator version 2.1.1.

Complete error message: TypeError: Drupal\views_aggregator\Plugin\views\style\Table::getCellRaw(): Return value must be of type string, Drupal\Core\Render\Markup returned in Drupal\views_aggregator\Plugin\views\style\Table->getCellRaw() (Zeile 754 in /opt/drupal/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php).

The call stack lists this
#0 /opt/drupal/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php(648): Drupal\views_aggregator\Plugin\views\style\Table->getCellRaw(Object(Drupal\webform_views\Plugin\views\field\WebformSubmissionField), Object(Drupal\views\ResultRow), true)

Steps to reproduce

I have a webform with the following element:

  sum_float:
    '#type': webform_computed_twig
    '#title': 'Sum as float'
    '#description': 'For Views aggregate'
    '#title_display': none
    '#display_on': none
    '#template': |-
      {% set sum = 0.0 %}
      {% for f in data.themen %}
          {% set val = f.betrag|trim|replace({',': '.'}) %}
          {% if (val) %}
            {% set sum = sum + val|round(2) %}
          {% endif %}
      {% endfor %}
      {{ sum|number_format(2) }}
    '#store': true
    '#ajax': true

Proposed resolution

Cast to a string.

Remaining tasks

Review changes.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Needs review

Version

2.1

Component

Code

Created by

🇩🇪Germany gogowitsch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024