Comments

Everett Zufelt’s picture

Status: Active » Needs review
StatusFileSize
new3.38 KB

@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.

Status: Needs review » Needs work

The last submitted patch, autocomplete.patch, failed testing.

Everett Zufelt’s picture

Status: Needs work » Needs review
StatusFileSize
new3.38 KB
jacine’s picture

subscribe.

Everett Zufelt’s picture

Status: Needs review » Needs work

It 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.

Everett Zufelt’s picture

Status: Needs work » Needs review
StatusFileSize
new3.47 KB

Allows usage of #autocomplete on form, textfield and password.

Everett Zufelt’s picture

StatusFileSize
new6.43 KB

I don't believe I have ever written tests before, and can't run tests locally, so let's see what happens here.

Status: Needs review » Needs work

The last submitted patch, autocomplete_4.patch, failed testing.

Everett Zufelt’s picture

Hoping that someone else can find the syntax error, as I have looked over the code a couple of times and don't see it.

Everett Zufelt’s picture

Status: Needs work » Needs review
StatusFileSize
new6.44 KB
moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks 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.

Everett Zufelt’s picture

@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.

jacine’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +D8H5

Go Everett go! :)

There's one minor issue with this:

+++ b/modules/simpletest/tests/form_test.moduleundefined
@@ -987,6 +993,29 @@ function form_test_select_submit($form, &$form_state) {
+
+    $form['textfield'] = array(
+    '#type' => 'textfield',
+    '#title' => 'textfield',
+    '#autocomplete' => 'off',
+  );

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.

Everett Zufelt’s picture

Status: Needs work » Needs review
StatusFileSize
new6.44 KB

Fixed indentation from #16.

jacine’s picture

Status: Needs review » Reviewed & tested by the community

Thanks Everett. Back to RTBC.

catch’s picture

Status: Reviewed & tested by the community » Needs work
+ *     #placeholder, #autocomplete, #required, #attributes, #autocomplete_path.

This 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.

Everett Zufelt’s picture

@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.

ericduran’s picture

+++ b/includes/form.incundefined
@@ -2743,6 +2743,7 @@ function form_process_password_confirm($element) {
+    '#autocomplete' => empty($element['#autocomplete']) ? NULL : $element['#autocomplete'],
+++ b/includes/form.incundefined
@@ -2750,6 +2751,7 @@ function form_process_password_confirm($element) {
+    '#autocomplete' => empty($element['#autocomplete']) ? NULL : $element['#autocomplete'],

The 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.

Everett Zufelt’s picture

@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?

Everett Zufelt’s picture

Status: Needs work » Needs review
xjm’s picture

StatusFileSize
new6.5 KB

Rerolled for core/.

sun’s picture

I'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.

cosmicdreams’s picture

So then should we close (won't fix) this issue. Is there a purpose for using HTML5's auto-complete over our current implementation?

mgifford’s picture

Issue tags: +autocomplete

Mostly tagging, but also pointing folks to a related issue #1512194: Use HTML5 datalists for autocomplete

lewisnyman’s picture

What's the status on this issue?

I'm about to implement this attribute in core:
#1955282: Disable Autocapitalize and Autocorrect on user login forms

mgifford’s picture

Issue tags: -autocomplete, -html5, -D8H5

#24: autocomplete-1275764-24.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +autocomplete, +html5, +D8H5

The last submitted patch, autocomplete-1275764-24.patch, failed testing.

mgifford’s picture

StatusFileSize
new1.84 KB

Well, 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....

jibran’s picture

Status: Needs work » Needs review
amontero’s picture

Issue tags: -autocomplete, -html5, -D8H5

#31: autocomplete-1275764-31.patch queued for re-testing.

jibran’s picture

31: autocomplete-1275764-31.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 31: autocomplete-1275764-31.patch, failed testing.

mgifford’s picture

Patch failed on SimplyTest.me too. @jibran or @amontero want to roll a new one?

mgifford’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new1.85 KB

Just a re-roll... Hope it passes now. Still don't see the expected output though.

sun’s picture

Title: Allow FAPI usage of the autocomplete attribute » Add a dedicated #autocomplete property to Form API form elements

Better 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.

mgifford’s picture

Issue tags: +html5

Thanks @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.

sqndr’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 37: autocomplete-1275764-36.patch, failed testing.

mgifford’s picture

Issue tags: +Needs reroll
rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new2.23 KB
prajaankit’s picture

StatusFileSize
new2.3 KB

autocomplete

Status: Needs review » Needs work

The last submitted patch, 45: autocomplete-1275764-45.patch, failed testing.

prajaankit’s picture

Assigned: Unassigned » prajaankit
Status: Needs work » Needs review
StatusFileSize
new0 bytes
prajaankit’s picture

StatusFileSize
new1.91 KB
prajaankit’s picture

StatusFileSize
new2.35 KB
tim.plunkett’s picture

Issue tags: -Needs reroll +Needs tests
  1. +++ b/core/includes/form.inc
    @@ -41,7 +41,7 @@ function drupal_form_submit($form_arg, FormStateInterface $form_state) {
    - *     Properties used: #title, #value, #options, #description, #extra,
    + *     Properties used: #action, #method, #attributes, #children, #autocomplete
      *     #multiple, #required, #name, #attributes, #size.
    

    It seems like this would just add #autocomplete, not sure why it removes others and duplicates #attributes.

  2. +++ b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php
    @@ -59,6 +60,7 @@ public static function processPasswordConfirm(&$element, FormStateInterface $for
    +      '#autocomplete' => empty($element['#autocomplete']) ? NULL : $element['#autocomplete'],  ¶
    

    Trailing whitespace here

This needs some automated testing.

joelpittet’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Needs review » Needs work

needs work for #50. 8.1 because its a feature

joelpittet’s picture

Assigned: prajaankit » Unassigned

Also why not use the existing API for attributes?


$element['#attributes']['autocomplete'] = 'on';
$element['#attributes']['autocomplete'] = 'off';

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank 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!

smustgrave’s picture

wanted to bump 1 more time before closing as this had a lot of traffic at the time (8 years ago)

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.