In a form, I have this field:
$form['payment'] = [ '#type' => 'radios', '#title' => $this->t('Payment Mode'), '#options' => [ 'chk' => $this->t('by check'), 'tfr' => $this->t('by bank transfer'), 'crd' => $this->t('by card'), ], '#required' => TRUE, ];
In the Twig template associated to the form, I’d like to show the field and some html stuff depending on the selected option. I tried this:
<form{{ attributes }}> {{ form.form_build_id }} {{ form.form_token }} {{ form.form_id }} <div> {{ form.payment }} {% if form.payment == 'chk' %} You chose 'Check' {% elseif form.payment == 'tfr' %} You chose 'Bank Transfer' {% elseif form.payment == 'crd' %} You chose 'Card' {% endif %} </div>
But it is nor working!
Any idea?