G
G
Genri_Rus2021-01-09 23:47:05
PHP
Genri_Rus, 2021-01-09 23:47:05

How to do the correct interpolation in twig with a ternary condition?

I have an input and the following condition:
The variable {{ value }} stores the value

{% set text = ( key_value != 'address' ? 'value="{{ value }}"' : '' ) %}

<input type="text" name="" {{ text }} class="" id="">

But this is how the name of the variable is displayed: "value", not its value

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Ezhgurov, 2021-01-09
@Genri_Rus

{% set text = ( key_value_cse != 'cse_address_street' ? ('value="' ~ value ~ '"') : '' ) %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question