Postponed (maintainer needs more info)
Project:
Drupal core
Version:
main
Component:
forms system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Sep 2011 at 16:56 UTC
Updated:
31 Oct 2025 at 14:37 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Everett Zufelt commentedSee related:
#787876: Edit "My Account" fills the first password field
#602784: Database password field autcomplete false
Comment #2
Everett Zufelt commentedSee related:
#787876: Edit "My Account" fills the first password field
#602784: Database password field autcomplete false
Comment #3
Everett Zufelt commented@autocomplete is valid on all input elements. I'm not certain if we want to do that.
This should add #autocomplete to password, text, and textarea.
Comment #5
Everett Zufelt commentedComment #6
jacinesubscribe.
Comment #7
Everett Zufelt commentedIt appears that this doesn't apply to textarea, but can apply to form, in which case children (or elements that are part of that form using the form attribute) inherit the value, but can override.
Will reroll to only apply to textfield, password, and form. Likely we will want to look at adding support for new input typs, such as tel, search, etc.
Comment #8
Everett Zufelt commentedAllows usage of #autocomplete on form, textfield and password.
Comment #9
Everett Zufelt commentedI don't believe I have ever written tests before, and can't run tests locally, so let's see what happens here.
Comment #11
Everett Zufelt commentedHoping that someone else can find the syntax error, as I have looked over the code a couple of times and don't see it.
Comment #12
Everett Zufelt commentedComment #13
Everett Zufelt commentedSee #1277282: Add support for #autocomplete to relevant Field API widgets
Comment #14
moshe weitzman commentedLooks good to me. We should doc in the FAPI reference that the only useful value here is 'off'. That's what the tests do so we have minimal doc already.
Comment #15
Everett Zufelt commented@moshe
Actually on is also a useful value.
In the edge case where a developer wants to mark all fields in a form as off, with the exception of one field, they can set #autocomplete off on the form and #autocomplete on for the specific element. I think this is an extreme edge case, but worth including in the docs.
Comment #16
jacineGo Everett go! :)
There's one minor issue with this:
The indentation needs to be fixed here. The $form line is indented 4 spaces instead of 2, and the properties need some indenting too. Otherwise, looks good.
Comment #17
Everett Zufelt commentedFixed indentation from #16.
Comment #18
jacineThanks Everett. Back to RTBC.
Comment #19
catchThis is going to be very confusing having #autocomplete/#autocomplete_path mean two completely different things that are not connected to each other.
http://api.drupal.org/api/drupal/includes--form.inc/function/theme_textf...
If we cleaned that up though, we might be able to remove #autcomplete_path from this list and reserve it for actual HTML stuff.
This doesn't necessarily need to depend on that clean up, but I'd like to find and/or open the issue to clean that up and have a decent plan of action in there (like a real autocomplete element or something). #125231: Enhance autocomplete feature looks like it might be the issue, although I feel like there's one for removing it from theme_textfield() somewhere too maybe.
Moving to needs work since we could at least use a comment or @todo explaining that the two have nothing to do with each other.
Comment #20
Everett Zufelt commented@Catch
Not sure of the best way to proceed, but the issue where the removal of autocomplete from theme_textfield() is mentioned is at #1174634-14: Add new HTML5 FAPI element: telephone.
Comment #21
ericduran commentedThe empty check shouldn't be needed.
Also if we're adding new form property to the element we should declare it in element declaration in system_element_info. This will eliminate the need to the empty check.
Comment #22
Everett Zufelt commented@ericduran
What do you recommend as the default value of '#autocomplete', ''? What does drupal_attributes() do with attributes with the empty string '' as their value?
Comment #23
Everett Zufelt commentedSee #1309394: Process #autocomplete_path for all form elements; remove custom/duplicated code from theme_textfield(), i'm not sure if this addresses catch's concern in #19.
Comment #24
xjmRerolled for core/.
Comment #25
sunI'm really not sure whether we need this. The autocomplete="off" attribute is used very rarely only.
The only difference this patch makes is that you specify
'#autocomplete' => 'off'instead of'#attributes' => array('autocomplete' => 'off').And for that, it needs to introduce explicit code in the theme functions of respective form elements to copy over the #property into #attributes, which means that #autocomplete only works for elements that support it explicitly - whereas #attributes][autocomplete works for any element.
It doesn't even process a more natural Boolean TRUE value into "no attribute" and FALSE into the special 'off' value. If that additional processing was contained, then I could vaguely see a DX point in adding #autocomplete.
Overall, this and some other related issues really cry for a Form API design specification that clarifies where we want to go and how much more code we want to introduce for dedicated #properties that map 1:1 to a key in #attributes, and/or what amount of (pre-)processing mandates a dedicated #property. Every dedicated #property adds to the code bloat issue in Form API, and also overall Drupal, since we suddenly also need dedicated tests for an element attribute that was formerly just simply part of #attributes.
Apparently, since the current incarnation of this patch only takes over the #autocomplete value as is into attributes, the tests being added here are merely testing the expected functionality of element_set_attributes(), which is sufficiently covered by other tests already. In other words: With the currently proposed #autocomplete "functionality", I don't see the point in adding tests -- they're needless, as they don't test any functionality that wouldn't be tested elsewhere already.
Comment #26
cosmicdreams commentedSo then should we close (won't fix) this issue. Is there a purpose for using HTML5's auto-complete over our current implementation?
Comment #27
mgiffordMostly tagging, but also pointing folks to a related issue #1512194: Use HTML5 datalists for autocomplete
Comment #28
lewisnymanWhat's the status on this issue?
I'm about to implement this attribute in core:
#1955282: Disable Autocapitalize and Autocorrect on user login forms
Comment #29
mgifford#24: autocomplete-1275764-24.patch queued for re-testing.
Comment #31
mgiffordWell, the function theme_textfield() & theme_password() have disappeared as have the functional tests. Leaving all we've got to re-roll the patch from #24 being this.
And that doesn't address @sun's concerns either....
Comment #32
jibranComment #33
amontero#31: autocomplete-1275764-31.patch queued for re-testing.
Comment #34
jibran31: autocomplete-1275764-31.patch queued for re-testing.
Comment #36
mgiffordPatch failed on SimplyTest.me too. @jibran or @amontero want to roll a new one?
Comment #37
mgiffordJust a re-roll... Hope it passes now. Still don't see the expected output though.
Comment #38
sunBetter issue title. Still not sure about this.
#autocomplete would be ambiguous with the existing #autocomplete_path, which has a related, but very different meaning.
It would make more sense to me if we'd design an actual "API" around the #autocomplete attribute - instead of only copying values from A to B.
Comment #39
mgiffordThanks @sun - I was going through old issues about HTML5 for a presentation I'm about to give. Thought I'd nudge this ahead, if only to get a patch that still applies. The API around #autocomplete sounds potentially quite useful.
Comment #41
sqndr commentedComment #43
mgiffordComment #44
rpayanmComment #45
prajaankit commentedautocomplete
Comment #47
prajaankit commentedComment #48
prajaankit commentedComment #49
prajaankit commentedComment #50
tim.plunkettIt seems like this would just add #autocomplete, not sure why it removes others and duplicates #attributes.
Trailing whitespace here
This needs some automated testing.
Comment #51
joelpittetneeds work for #50. 8.1 because its a feature
Comment #52
joelpittetAlso why not use the existing API for attributes?
Comment #68
smustgrave commentedThank you for sharing your idea for improving Drupal.
We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #69
smustgrave commentedwanted to bump 1 more time before closing as this had a lot of traffic at the time (8 years ago)