How to modify a form to have some field surrounded by 'Details'? I created a custom content entity with Drupal Console.
Three of its fields are defined this way:
// ----------------------------------------------------------------------------
    $weight++;
    $fields['picture'] = BaseFieldDefinition::create('image')
      -&gt;setLabel(t('Picture'))
      -&gt;setSettings([
        'file_extensions' =&gt; 'gif jpeg jpg png',
        'file_directory' =&gt; 'sel',
        'alt_field_required' =&gt; 0,
      ])
      -&gt;setCardinality(3)
      -&gt;setDisplayOptions('view', [
        'type' =&gt; 'default',
        'weight' =&gt; $weight,
      ])
      -&gt;setDisplayOptions('form', [
        'type' =&gt; 'image_image',
        'weight' =&gt; $weight,
      ])
      -&gt;setDisplayConfigurable('form', TRUE)
      -&gt;setDisplayConfigurable('view', TRUE);
// ----------------------------------------------------------------------------
    $weight++;
    $fields['file'] = BaseFieldDefinition::create('file')
      -&gt;setLabel(t('File'))
      -&gt;setSettings([
        'file_extensions' =&gt; 'pdf',
        'file_directory' =&gt; 'sel',
        'description_field' =&gt; TRUE,
      ])
      -&gt;setDisplayOptions('view', [
        'type' =&gt; 'file',
        'weight' =&gt; $weight,
      ])
      -&gt;setDisplayOptions('form', [
        'type' =&gt; 'file',
        'weight' =&gt; $weight,
      ])
      -&gt;setDisplayConfigurable('form', TRUE)
      -&gt;setDisplayConfigurable('view', TRUE);
// ----------------------------------------------------------------------------
    $weight++;
    $fields['link'] = BaseFieldDefinition::create('link')
      -&gt;setLabel(t('Link'))
      -&gt;setDisplayOptions('view', [
        'type' =&gt; 'link',
        'weight' =&gt; $weight,
      ])
      -&gt;setDisplayOptions('form', [
        'type' =&gt; 'link_default',
        'weight' =&gt; $weight,
      ])
      -&gt;setDisplayConfigurable('form', TRUE)
      -&gt;setDisplayConfigurable('view', TRUE);
// ----------------------------------------------------------------------------

And the corresponding form looks like this:

I would like to have the 'file' and the 'link' field in something like the 'Picture' field...
I updated buildForm :
public function buildForm(array $form, FormStateInterface $form_state)
  {
    $form = parent::buildForm($form, $form_state);
    $entity = $this-&gt;entity;
    $form['link']['widget']['0']['#type'] = 'details';
    return $form;
  }

And I got this:

How can I do the same for the 'File' field (have it surrounded in some 'Details')?
I did it this way (thanks to @4K4 to put me on the right direction):

$form['fileDetails'] = array(
  '#type' =&gt; 'details',
  '#title' =&gt; $this-&gt;t('File'),
  '#weight' =&gt; 8,
);
$form['file']['#group'] = 'fileDetails';

$form['link']['widget']['0']['#type'] = 'details';


And I get this: