fix(form): add labels shortcode attribute - #7576
Conversation
Add a labels attribute to [pods-form] (and [pods form=1]) so per-field labels can be overridden without a PHP template: [pods-form name="user" fields="user_nicename" labels="user_nicename:Utilizador"] - PodsForm::set_form_labels() / clear_form_labels() manage per-render overrides - PodsForm::label() applies the override for scalar labels - Overrides cleared via try/finally on every shortcode exit path - Gutenberg form block shortcode transforms keep the attribute - Tests: 6 unit tests covering set, clear, override, leak prevention Fixes pods-framework#7243
PR Summary
|
|
AI disclosure: this PR was written with Claude Opus 5 assistance, reviewed and tested by me. |
Review: the override works, but the new entry point is untestedThe mechanism is sound. The existing tests are real too: Three things to tighten. 1. Nothing tests
|
Description
Add a
labelsattribute to the[pods-form](and[pods form=1]) shortcode so per-field labels can be overridden from the shortcode itself. This is useful for built-in user fields likeuser_nicename,display_name, anduser_emailwhere labels are hardcoded in English and site translation tools do not pick them up.Usage:
The attribute uses
:as field:label separator and,as pair separator. Label values are sanitized withsanitize_text_field().Related GitHub issue(s)
Fixes #7243
Testing instructions
[pods-form name="user" fields="user_nicename,display_name" labels="user_nicename:Nickname,display_name:Full Name"]labelson the same page and confirm default labels still show (no leak)Screenshots / screencast
N/A — no visible UI changes beyond shortcode output labels.
Changelog text for these changes
Feature: You can now override per-field labels in the [pods-form] shortcode using the labels attribute. #7243 (@faisalahammad)
PR checklist