How to enable a field programmatically I've created a field programmatically :
$field_storage = FieldStorageConfig::create(
  array('entity_type' =&gt; 'node', 'field_name' =&gt; 'field_desc', 'type' =&gt; 'string'));
$field_storage-&gt;save();
$field = FieldConfig::create(
  array('entity_type' =&gt; 'node', 'field_name' =&gt; 'field_desc', 'bundle' =&gt; 'mybundle', 'settings' =&gt; array('handler' =&gt; 'default', 'handler_settings' =&gt; array())));
$field-&gt;save();

But the field is disabled by default when I access to &quot;manage form display&quot;.
My question is : how can I enable the field programatically?
thanks :)
You enable the field by adding a widget to the default form display mode:
$display_repository = \Drupal::service('entity_display.repository');

// Assign widget settings for the default form mode.
$display_repository-&gt;getFormDisplay('node', 'mybundle')
  -&gt;setComponent('field_desc', [
    'type' =&gt; 'string_textfield',
  ])
  -&gt;save();

See Add content type field programmatically