Using Drupal 8. I have a case where under certain conditions I need to disable a field when creating/editing a form. Thought i had done this before. function MYMODULE_form_alter(&$ form, FormStateInterface $ form_state, $ form_id) { if ($ form_id ==”node_xxx_edit_form” || $ form_id == “node_xxx_form” ){ $ form[‘field_yyy’][‘widget’][0][‘target_id’][‘#attributes’][‘disabled’] = ‘disabled’; $ form[‘field_zzz’][‘widget’][0][‘target_id’][‘#attributes’][‘disabled’] = ‘disabled’; …Read more