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 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 ?
Comment | File | Size | Author |
---|---|---|---|
#9 | 3002023-computed-filter-9.patch | 2.71 KB | bucefal91 |
#9 | interdiff-7-9.txt | 3.77 KB | bucefal91 |
#7 | 3002023-7.patch | 2.67 KB | John Cook |
#4 | Screen Shot 2018-09-28 at 1.34.55 PM.png | 156.04 KB | jrockowitz |
2018-09-24-213008_1920x1056_scrot.png | 82.99 KB | sorin_cocorada |
Comments
Comment #2
sorin_cocorada CreditAttribution: sorin_cocorada commentedComment #3
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedHello!
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.
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComputed element (if checked) can store values in the database which could be filterable by a View.
Comment #5
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedOh, 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.
Comment #6
sorin_cocorada CreditAttribution: sorin_cocorada commentedHello,
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.
Comment #7
John Cook CreditAttribution: John Cook at Creode commentedI'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.
Comment #8
sorin_cocorada CreditAttribution: sorin_cocorada commentedHello John,
I've applied you patch to my local installation and it seems to be ok. Now I can filter on Computed twig fields.
Comment #9
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedJohn, 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.
Comment #11
bucefal91 CreditAttribution: bucefal91 at Websolutions Agency commentedI have committed my patch.