That code doesn't enable Drupal's autocomplete (it would need the #autocomplete_path
property to do so), so I guess you mean the browser autocomplete?
The standard way to do that is to set the autocomplete
attribute on the element which you can do like this:
$form['plantuser']['username'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#description' => t(''),
'#required' => true,
'#maxlength' => 50,
'#weight' =>1,
'#attributes' => array('autocomplete' => 'off'),
);
Bear in mind autocomplete
is only valid using the HTML5 doctype; if you're using another doctype you'll need to implement a JS solution to set the attribute instead, e.g.
(function($) {
$(function() {
$('#input-id').attr('autocomplete', 'off');
});
})(jQuery);