Form type markup states Is it possible to create a form element of type markup and add a state to it, to make it visible on a condition? I can't seem to make it work and get the error:
Warning: Undefined array key &quot;#type&quot; in Drupal\Core\Form\FormHelper::processStates() (line 211 of core/lib/Drupal/Core/Form/FormHelper.php)
I need to just add some text in the form and make it visible on a condition.
Any help would be appreciated, thanks!
Adding form type item did the trick:
$form['my_incomes'] = [
      '#type' =&gt; 'item',
      '#markup' =&gt; $this-&gt;t('My other incomes'),
      '#states' =&gt; [
        'visible' =&gt; [
          [':input[name=&quot;marital_status&quot;]' =&gt; [['value' =&gt; 'single'],['value'=&gt;'couple']]],
        ]
      ]
    ];