Skip to content

Conversation

@mjauvin
Copy link
Member

@mjauvin mjauvin commented Jan 14, 2026

Related docs PR: wintercms/docs#255

phone:
    type: phone
    label: Phone number
    pattern: "[0-9]{3}-[0-9]{3}-[0-9]{4}"
    placeholder: xxx-xxx-xxxx
    minlength: 12
    maxlength: 20
    size: 20
image

Summary by CodeRabbit

  • New Features
    • Added a telephone input field widget with autocomplete and optional suggestions support.
    • Includes preview mode that displays telephone links when values are present.
    • Supports validation attributes and customizable field properties.

✏️ Tip: You can customize this high-level summary in your review settings.

@mjauvin mjauvin added this to the 1.2.10 milestone Jan 14, 2026
@mjauvin mjauvin requested a review from LukeTowers January 14, 2026 21:39
@mjauvin mjauvin self-assigned this Jan 14, 2026
@mjauvin mjauvin added the enhancement PRs that implement a new feature or substantial change label Jan 14, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 14, 2026

Walkthrough

A new PHP partial template has been added to render a telephone input field. The template supports two modes: preview mode displays a tel link or placeholder, while standard mode renders an input element with optional autocomplete, validation attributes, and a datalist for suggestions.

Changes

Cohort / File(s) Change Summary
New Form Field Partial
modules/backend/widgets/form/partials/_field_phone.php
Introduces telephone input field template with dual-mode rendering: preview displays tel link/placeholder; standard mode renders input with dynamic attributes (autocomplete, maxlength, minlength, pattern, placeholder, size), datalist support for suggestions with auto-translated labels, and proper output escaping

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add phone form field' directly and clearly describes the main change: introducing a new phone form field type to the application.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@modules/backend/widgets/form/partials/_field_phone.php`:
- Line 1: The file’s top HTML comment incorrectly reads "URL" due to copy-paste;
update the comment in the _field_phone.php partial to say "Phone" (or a more
descriptive "Phone field") so it accurately reflects the field purpose; locate
the comment token at the top of the partial and replace the text "URL" with
"Phone".
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4bd85f and feda831.

📒 Files selected for processing (1)
  • modules/backend/widgets/form/partials/_field_phone.php
🧰 Additional context used
🧬 Code graph analysis (1)
modules/backend/widgets/form/partials/_field_phone.php (1)
modules/backend/classes/FormField.php (3)
  • options (228-246)
  • size (217-221)
  • getAttributes (431-445)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: windows-latest / PHP 8.3
  • GitHub Check: windows-latest / PHP 8.1
  • GitHub Check: ubuntu-latest / PHP 8.4
  • GitHub Check: ubuntu-latest / PHP 8.1
  • GitHub Check: windows-latest / PHP 8.2
  • GitHub Check: windows-latest / PHP 8.4
  • GitHub Check: ubuntu-latest / PHP 8.3
  • GitHub Check: ubuntu-latest / PHP 8.2
  • GitHub Check: windows-latest / JavaScript
🔇 Additional comments (3)
modules/backend/widgets/form/partials/_field_phone.php (3)

11-23: LGTM!

Preview mode implementation is well-structured with proper security measures (target="_blank" paired with rel="noopener noreferrer") and consistent output escaping via e().


25-39: Implementation looks good with one note on size attribute semantics.

The conditional attribute rendering with type validation is well done. The is_numeric($field->size) check on line 36 correctly filters out the framework's string-based size values (like 'large'), avoiding conflict with the HTML size attribute.

Based on the relevant snippet showing FormField::size() defaults to 'large', the numeric check ensures only explicit numeric values set the HTML attribute. Consider documenting this distinction in the field's YAML documentation to avoid confusion between the framework's size property and the HTML input's size attribute.


40-47: LGTM!

The datalist implementation correctly handles both associative and sequential arrays via the integer key check on line 43, and properly applies translation to labels for i18n support.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@@ -0,0 +1,49 @@
<!-- URL -->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Incorrect comment: should be "Phone" not "URL".

This appears to be a copy-paste artifact from another field partial.

Suggested fix
-<!-- URL -->
+<!-- Phone -->
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<!-- URL -->
<!-- Phone -->
🤖 Prompt for AI Agents
In `@modules/backend/widgets/form/partials/_field_phone.php` at line 1, The file’s
top HTML comment incorrectly reads "URL" due to copy-paste; update the comment
in the _field_phone.php partial to say "Phone" (or a more descriptive "Phone
field") so it accurately reflects the field purpose; locate the comment token at
the top of the partial and replace the text "URL" with "Phone".

@LukeTowers
Copy link
Member

@mjauvin can you do up a docs PR for this field too? ❤️

@mjauvin
Copy link
Member Author

mjauvin commented Jan 14, 2026

@mjauvin can you do up a docs PR for this field too? ❤️

Done!

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

Labels

enhancement PRs that implement a new feature or substantial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants