0

I have a webform with a Checkbox (i.e. boolean) field called 'Paid'; I'm using webform_views to include and rewrite it in a view (there's some extra code which adds a link to the payment page, but I've stripped that out for these purposes.)

Replacement Pattern section: {{ webform_submission_value_1 }} == Paid

Format: set to raw value (i.e. 0 or 1 rather than Yes/No)

Twig: (in 'Override the output of this field with custom text')

Value: {{ webform_submission_value_1 }}

Conditional: 

{% if webform_submission_value_1 == 1 %}
  paid
{% else %}
  not paid
{% endif %}

Output:

Value: 0 Conditional: paid

and if edit the form and toggle the value:

Value: 1 Conditional: paid

NB: the view is more complicated that this and there are other fields, but they all seem to behaving correctly. Also there are access restrictions on the Paid field for non-administrators, but even with these on the View seems to be able to display the value correctly.

4
  • 1
    try {% if webform_submission_value_1|strip_tags == 1 %}
    – No Sssweat
    Aug 6, 2018 at 4:40
  • @NoSssweat still the same... Aug 6, 2018 at 7:33
  • 1
    @NoSssweat aha - just noticed I was getting an XHR error when updating the preview - striptags without the underscore works. Thank you! Aug 6, 2018 at 7:49
  • yeah my bad, the twig version doesn't have underscore. Alternatively if you don't want to have to use striptags you could uncheck some settings in Views UI. Can't remember if screenshot 1 alone will do, if not, also do screenshot 3.
    – No Sssweat
    Aug 6, 2018 at 18:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.