I have a content type with an image field. Users can create the content and upload an image. I'd like to not allow users to change/remove the image once it was uploaded, but still show the image on the node edit form. So I only need to disable/remove the 'remove' button from the image field. I tried the following (via hook_form_alter), but it didn't work:
$form['field_image']['#disabled'] = TRUE;
The below works, but it hides the image element completely, which is not what I'm after:
$form['field_image']['#access'] = FALSE;
Please help to find a workaround.
You have to use the hook_field_widget_form_alter function and inside there look for the variable details using dpm() and then alter the button using an attribute from the Forms API.
But I would suggest to make the widget field read only on the edit form and not remove the delete button.
Useful issues: