How do I check radio buttons in Twig template? In a form, I have this field:  

$form['payment'] = [
  '#type' =&gt; 'radios',
  '#title' =&gt; $this-&gt;t('Payment Mode'),
  '#options' =&gt; [
    'chk' =&gt; $this-&gt;t('by check'),
    'tfr' =&gt; $this-&gt;t('by bank transfer'),
    'crd' =&gt; $this-&gt;t('by card'),
  ],
  '#required' =&gt; 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:  

&lt;form{{ attributes }}&gt; {{ form.form_build_id }} {{ form.form_token }} {{ form.form_id }}
  &lt;div&gt;
    {{ 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 %}
  &lt;/div&gt;


But it is nor working!
Any idea?
That's a task for #states not for Twig. I think this also could be ajaxified a little bit more elegantly but using #states on some items does the job as well.

$form['payment'] = [
  '#type' =&gt; 'radios',
  '#title' =&gt; $this-&gt;t('Payment Mode'),
  '#options' =&gt; [
    'chk' =&gt; $this-&gt;t('by check'),
    'tfr' =&gt; $this-&gt;t('by bank transfer'),
    'crd' =&gt; $this-&gt;t('by card'),
  ],
  '#required' =&gt; TRUE,
];

$form['chk'] = [
  '#type' =&gt; 'item',
  '#markup' =&gt; $this-&gt;t("You chose 'Check'"),
  '#states' =&gt; [
    'visible' =&gt; [
      ':input[name="payment"]' =&gt; ['value' =&gt; 'chk'],
    ],
  ],
];

$form['tfr'] = [
  '#type' =&gt; 'item',
  '#markup' =&gt; $this-&gt;t("You chose 'Bank Transfer'"),
  '#states' =&gt; [
    'visible' =&gt; [
      ':input[name="payment"]' =&gt; ['value' =&gt; 'tfr'],
    ],
  ],
];

$form['crd'] = [
  '#type' =&gt; 'item',
  '#markup' =&gt; $this-&gt;t("You chose 'Card'"),
  '#states' =&gt; [
    'visible' =&gt; [
      ':input[name="payment"]' =&gt; ['value' =&gt; 'crd'],
    ],
  ],
];