fix: evaluate shortcodes in field default value - #7593
Open
faisalahammad wants to merge 4 commits into
Open
Conversation
When a field has Allow Shortcodes enabled and a shortcode is set in its Default Value, the shortcode stayed literal in the form until the item was first saved. The per-type allow_shortcode flag was only read in each field's display() method, not in the central PodsForm::default_value() resolver that runs at form render time. Evaluate the shortcode in default_value() when the field type opts in, nested inside the existing default_evaluate_tags block so only the configured default is processed, never request-supplied values. Fixes pods-framework#7021
faisalahammad
requested review from
JoryHogeveen and
sc0ttkclark
as code owners
August 9, 2026 15:29
Contributor
Author
|
AI disclosure: this PR was written with Claude Opus 5 assistance, reviewed and tested by me. |
do_shortcode() was nested inside the magic-tag branch, which is only entered
when str_replace() actually removed a '{@' or '}' from the default. A default
such as 'Today is [current_year]' therefore never reached do_shortcode() and
was rendered literally.
Shortcode expansion is a separate opt-in ({type}_allow_shortcode) from magic
tag evaluation (default_evaluate_tags), so it now runs in a sibling condition.
It deliberately still runs before the default_value_parameter override so that
request-supplied values are never passed through do_shortcode().
Refs pods-framework#7021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a field has Allow Shortcodes enabled and a shortcode is set in its Default Value, the shortcode stayed literal in the form until the item was first saved. The per-type
{type}_allow_shortcodeflag was only read in each field'sdisplay()method, not in the centralPodsForm::default_value()resolver that runs at form render time.Fix: evaluate the shortcode in
PodsForm::default_value()when the field type opts in, nested inside the existingdefault_evaluate_tagsblock so only the configured default is processed, never request-supplied values.Single-point fix in the central resolver covers every caller: the frontend form (
classes/PodsForm.php:258), the threePodsAPI::save_postsites (classes/PodsAPI.php:5078, 5105, 5191), andPodsField::build_dfv_field_data()(classes/PodsField.php:475).Backward compatibility:
do_shortcode()is idempotent. Unregistered shortcodes return unchanged.pods_form_field_default_valuefilter preserved at same priority.{@...}still resolved first.{type}_allow_shortcode(e.g.pick,file,number) untouched.default_value_parameterstay literal (security).Related GitHub issue(s)
Fixes #7021
Testing instructions
Today is [current_year](or any shortcode registered on the site).Today is 2026, not the literal[current_year].[current_year](pre-fix behavior).pickfield whose default is[anything]. Literal text preserved (nopick_allow_shortcodeoption).PHP tests (run via SLIC):
JS tests:
Screenshots / screencast
Not applicable (no UI change visible to end users; the fix only changes what text is rendered in the form input on new item creation).
Changelog text for these changes
Bug: Shortcodes in Pods field Default Value are now evaluated in the form when Allow Shortcodes is enabled. #7021
PR checklist