Computed twig element does not work with php 8.0

Created on 19 April 2022, over 2 years ago
Updated 15 February 2023, over 1 year ago

Problem/Motivation

Computed twig element does not work with Drupal's recommended php 8.0 version

πŸ’¬ Support request
Status

Fixed

Version

6.1

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia sophron

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States stephenplatz

    I'm not sure if this is the same issue, I'm using PHP 8.1. The following always results in a Division by Zero error:

    numerator:
      '#type': number
      '#title': Numerator
      '#states':
        visible:
          ':input[name="metric_type"]':
            value: Percentage
    denominator:
      '#type': number
      '#title': Denominator
      '#states':
        visible:
          ':input[name="metric_type"]':
            value: Percentage
      '#min': 1
    calculated_percentage:
      '#type': computed_twig
      '#title': 'Calculated %'
      '#title_display': none
      '#description_display': invisible
      '#template': '{{( data.numerator / data.denominator )}}'

    This is also the case using the number_format filter.

  • πŸ‡ΊπŸ‡ΈUnited States stephenplatz
Production build 0.71.5 2024