Preprocess a Paragraph when Added to Content Type I'm trying to disable a field in a Paragraph when it's added to a certain content type. Currently I'm using the following:

function my_module_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  switch($form_id) {
    case "node_content_type_form":
        $form['field_paragraph_content']['widget'][0]['subform']['field_paragraph_field']['#disabled'] = 'disabled';
      break;
  }
}


This works only after the node containing the paragraph has already been saved. When the paragraph in question is first added to the node the field_paragraph_field is not disabled. 

How can I preprocess the Paragraph form when it is initially added to the content type so this field is always disabled?
If you want it to work when creating a node and when editing the node, you should make the change using both the node add form and the node edit form:

mymodule_form_node_content_type_form_alter()

mymodule_form_node_content_type_edit_form_alter()


Or in your hook_form_alter in the question:

case "node_content_type_form":
case "node_content_type_edit_form":


There's another way to do this using hook_field_widget_form_alter():

function mymodule_field_widget_form_alter(&amp;$element, FormStateInterface $form_state, $context) {

  if ($context['items']-&gt;getFieldDefinition()-&gt;getTargetBundle() == 'content_type' &amp;&amp; $context['items']-&gt;getFieldDefinition()-&gt;getName() == 'field_paragraph_field') {
    $element['#disabled'] = TRUE;
  }

}