How to add an attribute in an input date field I want add the attribute autocomplete="Off" in the input field of the date field.
I've created a modulo with hook_form_alter but not works.
This is my code:

function no_input_autocomplete_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    if($form_id === 'prenotazione_node_form'){
        $form['field_periodo_prenotazione_to']['#attributes'] = array('autocomplete' =&gt; 'Off');
    }
}


I've noticed that with other field type works as I expect.

How can solve it?
Try with

$form['field_periodo_prenotazione_to']['widget'][0]['value']['#attributes'] = array('autocomplete' =&gt; 'Off');