Conditional fields for the field type 'managed_file' is not working in Drupal 8 I have two radio buttons


Enter The Text 
Upload a Text File


If user select the 1st option, a field of type 'textfield' will appear &amp; if they select the 2nd option, a field of type 'managed_file' will appear.
 But this code with working fine for textfield but not working for managed_file
 Now, how to implement conditional fields in Drupal 8 ?

This is my D8 code.

    $form['field_type'] = array(
    '#type'    =&gt; 'radios',
    '#options' =&gt; array_combine( array(t('Enter The Text'), t('Upload a Text File'))
                                 array(t('Enter The Text'), t('Upload a Text File'))
                                ),
    '#title'   =&gt; t('Choose entry type.')
  );

  $form['imgurl'] = array(
    '#type'          =&gt; 'textfield',
    '#title'         =&gt; t('Enter the text'),
    '#states'        =&gt; array(
      'visible'      =&gt; array(
        ':input[name="field_type"]' =&gt; array('value' =&gt; t('Enter The Text')),
      ),
    ),
  );

  $form['file'] = array(
    '#title'              =&gt; t('Choose Text File'),
    '#type'               =&gt; 'managed_file',
    '#progress_indicator' =&gt; 'throbber',
    '#progress_message'   =&gt; NULL,
    '#upload_location'    =&gt; 'public://files/',
    '#states'             =&gt; array(
      'visible'           =&gt; array(
        ':input[name="field_type"]' =&gt; array('value' =&gt; t('Upload a Text File')),
      ),
    ),
  );
I don't know, if this as anything to do with managed files, but I think #options should look like this:

'#options' =&gt; array(
  'text' =&gt; t('Enter The Text'),
  'upload' =&gt; t('Upload a Text File'),
),


and in #states the options key, not the translatable value:

'#states' =&gt; array(
  'visible' =&gt; array(
    ':input[name="field_type"]' =&gt; array('value' =&gt; 'text'),
  ),
),


If it has something to do with managed_file, then this old issue is back:

https://www.drupal.org/node/1118016

You can check this by changing temporarily managed_file to file.