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(&$form, &$form_state, $form_id) {
    if($form_id === 'prenotazione_node_form'){
        $form['field_periodo_prenotazione_to']['#attributes'] = array('autocomplete' => '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' => 'Off');
  • I've already try this but not works – kb8 Jun 8 '18 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.