How to load paragraphs fields in hook_form_alter to disallow access? I have a field inside a paragraph referenced in an taxonomy term.

/**
 * Implements hook_form_alter()
 */
function custom_general_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
  switch ($form_id) {
    case 'taxonomy_term_application_category_form':
        $entity = $form_state-&gt;getFormObject()-&gt;getEntity();
        kint($entity);
        break;
  }
}


Inside Paragraph field named field_test_para, 
I have a text field named field_text,
how can I fetch array structure of field_text in order to hide the field_text and how can disallow access to the text field. So far, I have managed to get the taxonomy entity and looking on how I can fetch paragraph entity and then alter the #access parameter of text field within it.
Maybe you can use a preprocess paragraphs function which will target it more easily

function mymodule_preprocess_paragraph__myparagraph(&amp;$vars)
{
    if ($vars['view_mode'] == 'full') {
        $parag = $vars['paragraph'];
        if (SOME LOGIC HERE){
        unset($vars['content']['myfield']);
        $var['field_removed']=true;
    }
}


The key point is to replace __myparagraph with the id of your paragraph

This example show you:


How to access the paragraph object $parag = $vars['paragraph'];
How to handle your logic only for a view mode ($vars['view_mode'] == 'full')
Remove a field unset($vars['content']['myfield']);
You can test the variable field_removed in your twig template to not run the code to display the field (optional)


Oups, it looks like you are asking to alter a paragraph's form...
For this you can use hook_field_widget_paragraphs_form_alter

function maymodule_field_widget_paragraphs_form_alter(&amp;$element, FormStateInterface &amp;$form_state, $context)
{
    switch ($element['#paragraph_type']) {
        case 'myparagraphs':
            $term = $form_state-&gt;getFormObject()-&gt;getEntity();
            //Check if paragraph is inside a form term
            if($term &amp;&amp; ($term-&gt;getEntityTypeId()=='taxonomy_term')){
                $voc=$term-&gt;bundle();
                //Check if it is the desired voc
                if($voc=='my_voc'){
                    //unset($element['subform']['field_to_be hidded']); //to hide only one field
                    $element=[]; //to hide all the form
                }
            }
            break;
    }
}


Hope this help