Disable field date and checkbox I'm trying to disable input fields of type date and checkbox in hook_form_alter with above code:

$key = 'field_name';

$form[$key]['widget'][0]['value']['#attributes']['disabled'] = true;
$form[$key]['widget']['#attributes']['disabled'] = true;
$form[$key]['widget'][0]['#attributes']['disabled'] = true;
$form[$key]['widget'][0]['target_id']['#attributes']['disabled'] = true;
$form[$key]['widget'][0]['#attributes']['disabled'] = true;
$form[$key]['#disabled'] = 'disabled';
$form[$key]['widget']['#attributes']['readonly'] = 'readonly';


Disabled all fields (type text or entity reference) but not work for checkbox and date fields.
Any ideas for solve this?
This is how to disable the field:

$form[$key]['widget'][0]['value']['#attributes']['disabled'] = 'disabled';