Skip to content

Rails hidden fields now fail W3C HTML Validation due to "autocomplete=off" #46470

@mattscilipoti

Description

@mattscilipoti

The W3C HTML Validator was updated on 2022/10/26, in validator/validator#1458, to conform to https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute. The validator now identifies an issue with hidden fields, due to #42610.

Steps to reproduce

Add a hidden field to a form, via various methods (including authenticity_token) and test the rendered form via W3C Html Validator.

I looked at the various test cases, but I don't see how to render a control on a form.

# Your reproduction script goes here

Expected behavior

I'm not clear about this. For this use case, I think the html spec is saying the autocomplete attribute should simply not be there. They discuss using an ordered set of space-separated tokens, but I haven't found how that would be applicable.

Actual behavior

All hidden fields have autocomplete="false".

System configuration

Rails version: 7.0.1

Ruby version: 3.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions