Skip to content

Allow overriding autocomplete attribute on text, number, and textar… - #1613

Open
rebaz88 wants to merge 1 commit into
wintercms:developfrom
rebaz88:develop
Open

rebaz88 wants to merge 1 commit into
wintercms:developfrom
rebaz88:develop

Conversation

@rebaz88

@rebaz88 rebaz88 commented Dec 3, 2026 •

Copy link
Copy Markdown

Summary

Prevents duplicate autocomplete attributes when a custom autocomplete attribute is configured on text, number, or textarea backend form fields.

Problem

Currently, _field_text.php, _field_number.php, and _field_textarea.php hardcode autocomplete="off" before <?= $field->getAttributes() ?>. When a field defines a custom autocomplete attribute in its YAML or PHP config, e.g.:

address:
    label: Address
    type: text
    attributes:
        autocomplete: street-address

the rendered HTML outputs two autocomplete attributes (autocomplete="off" autocomplete="street-address"), causing browsers to ignore the custom value.

Solution

Conditionally render autocomplete="off" only when $field->hasAttribute('autocomplete') is false, matching the existing pattern in modules/backend/widgets/form/partials/_field_password.php:

<?= $field->hasAttribute('autocomplete') ? '' : 'autocomplete="off"' ?>

Updated partials:

  • modules/backend/widgets/form/partials/_field_text.php
  • modules/backend/widgets/form/partials/_field_number.php
  • modules/backend/widgets/form/partials/_field_textarea.php

Backwards Compatibility

Fully backwards-compatible: fields without a custom autocomplete attribute continue to render autocomplete="off" as before.

Summary by CodeRabbit

  • Bug Fixes
    • Number, text, and textarea fields now retain their configured autocomplete settings instead of overriding them with off.
    • Fields without a configured autocomplete setting continue to use autocomplete="off".

…ea form fields

Only output the default `autocomplete="off"` attribute when the field does
not define a custom `autocomplete` attribute, matching the existing
behavior in `_field_password.php`.
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The number, text, and textarea templates now add autocomplete="off" only when the field does not already define an autocomplete attribute. Previously, each template always added the default attribute.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: Minimal · up to 1e69d

This change stops duplicate autocomplete attributes on backend text, number, and textarea fields when a custom value is set. Fields without a custom value still render autocomplete="off". The risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title says the change allows overriding the autocomplete attribute on text, number, and textarea fields. The raw summary and PR objectives both describe this: the three partials now emit autocompl…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title says the change allows overriding the autocomplete attribute on text, number, and textarea fields. The raw summary and PR objectives both describe this: the three partials now emit autocomplete="off" only when the field has no custom autocomplete attribute. The title is truncated at the end ("textar…"), but the main change is still clear.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a2bb860f-2242-4039-9bff-f81792c4c52b
Commits

Reviewing files that changed from the base of the PR and between 93470f6 and 1e69d5d.

Files selected for processing: 3

  • modules/backend/widgets/form/partials/_field_number.php
  • modules/backend/widgets/form/partials/_field_text.php
  • modules/backend/widgets/form/partials/_field_textarea.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant