Hello ,
I have successfully added Computed Twig/Token fields to a Webform View and they are correctly displayed; but when I try to implement a filter based on these fields the token itself is showed in the text input instead of allowing me to specify the text. The same happens when I try to expose the filter.

Is this the expected behaviour ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sorin_cocorada created an issue. See original summary.

sorin_cocorada’s picture

Component: Miscellaneous » Code
bucefal91’s picture

Hello!

Ehm.. to be honest I cannot think of a way how we could support a computed Twig/Token element because it's value is calculated on-the-fly, it's not stored in the database and views filters they operate on the database level.

I am afraid the only thing I can do is to remove the filter from the UI so it does not mislead people.

jrockowitz’s picture

Computed element (if checked) can store values in the database which could be filterable by a View.

bucefal91’s picture

Oh, I wasn't aware of that and just did not check before stating my position. Then I am taking my words back. I'll go and have a look if there's anything worthwhile that I can do.

sorin_cocorada’s picture

Hello,
I forgot to mention in the problem description, I have checked "Store value in the database". The problem appears not only when exposing the filter but also when using it hidden.

John Cook’s picture

Category: Support request » Feature request
Status: Active » Needs review
FileSize
2.67 KB

I've made a start on a patch for this.

A new WebformElementView has been created for Computed Twig components, along with a filter class.

I've only looked at the Computed Twig element, but it might work with the token element with a bit of tweaking.

This required the "Store value in the database" option to be checked – the filter isn't available if this hasn't been enabled.

sorin_cocorada’s picture

Hello John,
I've applied you patch to my local installation and it seems to be ok. Now I can filter on Computed twig fields.

bucefal91’s picture

John, thank you for contributing :)

Your patch does the job :) I only decided to amplify it, since dealing with computed elements, to cover Token element too.

I am attaching an interdiff + the new patch which covers both Twig and Token elements. I tested it locally on both elements and it worked just fine.

  • bucefal91 committed 09e2826 on 8.x-5.x
    Issue #3002023 by John Cook, bucefal91: Introducing filtering on...
bucefal91’s picture

Status: Needs review » Fixed

I have committed my patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.