Skip to content

Show IDs in page and View dropdown labels - #3684

Draft
Crabcyborg wants to merge 7 commits into
masterfrom
feat/post-dropdown-labels
Draft

Crabcyborg wants to merge 7 commits into
masterfrom
feat/post-dropdown-labels

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Use a shared title-and-ID label for page and View choices, including autocomplete results and selected values. Give untitled posts a readable fallback and retain the ID when a title is truncated.

The page autocomplete search strips a trailing "(ID: n)" from the term, so a prefilled label can be edited, and an all-digit term also matches the post ID. The selected autocomplete value keeps the Private and Protected title prefixes.

Companion Pro PR: https://github.com/Strategy11/formidable-pro/pull/6973 (uses FrmAppHelper::get_post_dropdown_label() in the gated-content access-page selector).

Testing

  • Dropdown regression tests: 6 tests and 22 assertions passed, including page search by prefilled label and by ID, and the private title prefix on the selected autocomplete value.
  • Scoped PHP syntax, PHPCS, Rector, PHP CS Fixer and Mago lint and analysis passed.

Remaining draft validation

Review duplicate titles, untitled pages, long titles, selected autocomplete values and gated-content choices in the browser.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
Pre-merge checks: Passed 1 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Passed Passed checks: 1 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • 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

@deepsource-io

deepsource-io Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in ab4ee48...339e325 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Nov 18, 2026 7:50p.m. Review ↗
JavaScript Nov 18, 2026 7:50p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

'post_title' => $title,
);
$expected = '' === trim( $title ) ? FrmFormsHelper::get_no_title_text() : $title;
$this->assertSame( $expected . ' (ID: 123)', FrmAppHelper::get_post_dropdown_label( $post ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

);
$expected = '' === trim( $title ) ? FrmFormsHelper::get_no_title_text() : $title;
$this->assertSame( $expected . ' (ID: 123)', FrmAppHelper::get_post_dropdown_label( $post ) );
$this->assertSame( $title, $post->post_title );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

'post_title' => str_repeat( 'Long title ', 20 ),
);
$label = FrmAppHelper::get_post_dropdown_label( $post, 30 );
$this->assertStringContainsString( '(ID: 456)', $label );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertStringContainsString()


The method you are trying to call is not defined, which can result in a fatal error.

);
$label = FrmAppHelper::get_post_dropdown_label( $post, 30 );
$this->assertStringContainsString( '(ID: 456)', $label );
$this->assertLessThan( strlen( $post->post_title ), strlen( $label ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertLessThan()


The method you are trying to call is not defined, which can result in a fatal error.


/** @return void */
public function test_page_dropdown_preserves_selection_and_escapes_titles() {
$id = self::factory()->post->create(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined static method test_FrmPostDropdownLabels::factory()


Invalid call to a static method. This would lead to a run time error.

$this->assertStringContainsString( 'A & B (ID: ' . $id . ')', $html );
$this->assertStringContainsString( "id='destination-id'", $html );
remove_filter( 'list_pages', array( 'FrmAppHelper', 'page_dropdown_label' ), 10 );
$this->assertFalse( has_filter( 'list_pages', array( 'FrmAppHelper', 'page_dropdown_label' ) ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertFalse()


The method you are trying to call is not defined, which can result in a fatal error.


/** @return void */
public function test_shared_page_dropdown_uses_no_title() {
$id = self::factory()->post->create(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined static method test_FrmPostDropdownLabels::factory()


Invalid call to a static method. This would lead to a run time error.

)
);
$html = ob_get_clean();
$this->assertStringContainsString( '(no title) (ID: ' . $id . ')', $html );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertStringContainsString()


The method you are trying to call is not defined, which can result in a fatal error.

);
$html = ob_get_clean();
$this->assertStringContainsString( '(no title) (ID: ' . $id . ')', $html );
$this->assertStringContainsString( 'value="' . $id . '"', $html );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertStringContainsString()


The method you are trying to call is not defined, which can result in a fatal error.

),
true
);
$this->assertSame(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.

@Crabcyborg Crabcyborg added this to the 7.1 milestone Nov 10, 2026
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 10, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request Changes on the current head. This is a draft, and the PR body lists browser validation as still to do. I ran the PHPUnit side and probed the autocomplete search path; one item needs fixing, the rest are smaller.

  1. Should fix before ready: the autocomplete input is now pre-filled with Title (ID: n), but FrmSettingsController::page_search() still searches post_title LIKE term. Editing the pre-filled text finds nothing, and typing an ID finds nothing either (reproduced, see inline).
  2. Non-blocking: FrmAppHelper::page_dropdown_label() is never hooked anywhere in the plugin, only in the new test (see inline).
  3. Non-blocking: the selected autocomplete value now comes from get_post() instead of get_the_title(), so the Private: / Protected: title prefix is dropped (Secret now, Private: Secret before).

Tests run: vendor/bin/phpunit tests/phpunit/misc/test_FrmPostDropdownLabels.php at 89757f3 → OK (5 tests, 19 assertions). CI did not run PHPUnit, PHPCS or PHPStan on this draft, so this local run is the only execution. Not run in a browser: selected autocomplete values and long-title truncation, which the PR body also lists as open.

$results[] = array(
'value' => $page->ID,
'label' => $page->post_title,
'label' => FrmAppHelper::get_post_dropdown_label( $page ),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should fix. The label now carries (ID: n), but the query above it still only matches post_title. I ran the same FrmDb::get_results( $wpdb->posts, array( ..., 'post_title LIKE' => $term ), ... ) against a published page titled Saved Listings (ID 24):

  • term Saved Listings → 1 row
  • term Saved Listings (ID: 24) → 0 rows
  • term 24 → 0 rows

So the pre-filled value (FrmAppHelper::maybe_autocomplete_pages_options()) cannot be refined without losing every match, and the ID that this PR is adding cannot be used to find the page. Fix: strip a trailing (ID: n) from the term and also match an all-digit term against ID. Sketch:

$term = preg_replace( '/\s*\(ID: \d+\)\s*$/', '', $term );

and extend $where with an ID OR clause when ctype_digit( $term ). Add a test that calls page_search() (or the query) with a prefilled label and with a numeric ID.

Comment thread classes/helpers/FrmAppHelper.php Outdated
*
* @return string
*/
public static function page_dropdown_label( $title, $page ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking. page_dropdown_label() has no caller in the plugin (grep -rn page_dropdown_label classes paypal stripe square js/src finds only this definition). Only test_page_dropdown_preserves_selection_and_escapes_titles hooks it onto list_pages, so that test proves the filter works when a test hooks it, not that any real page dropdown shows IDs. Either hook it where a Formidable screen calls wp_dropdown_pages() (none does in Lite today; Pro may), or drop the method and that test until the caller exists.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 10, 2026
The page autocomplete now strips a trailing "(ID: n)" from the search
term and matches an all-digit term against the post ID, so a prefilled
label can be edited and a page can be found by ID.

Keep the Private and Protected title prefix on the selected autocomplete
value, and drop the unused page_dropdown_label() filter callback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

foreach ( array( 'Saved Listings', 'Saved Listings (ID: ' . $id . ')', 'Saved', (string) $id ) as $term ) {
$values = wp_list_pluck( FrmSettingsController::get_page_search_results( $term, 'page' ), 'value' );
$this->assertContains( (string) $id, array_map( 'strval', $values ), 'Term: ' . $term );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertContains()


The method you are trying to call is not defined, which can result in a fatal error.

}

$results = FrmSettingsController::get_page_search_results( 'Saved Listings', 'page' );
$this->assertSame( 'Saved Listings (ID: ' . $id . ')', $results[0]['label'] );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.


$results = FrmSettingsController::get_page_search_results( 'Saved Listings', 'page' );
$this->assertSame( 'Saved Listings (ID: ' . $id . ')', $results[0]['label'] );
$this->assertSame( array(), FrmSettingsController::get_page_search_results( 'No such page', 'page' ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertSame()


The method you are trying to call is not defined, which can result in a fatal error.


/** @return void */
public function test_autocomplete_selected_value_keeps_private_prefix() {
$id = self::factory()->post->create(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined static method test_FrmPostDropdownLabels::factory()


Invalid call to a static method. This would lead to a run time error.

'post_title' => 'Secret',
)
);
self::factory()->post->create_many(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined static method test_FrmPostDropdownLabels::factory()


Invalid call to a static method. This would lead to a run time error.

)
);
$html = ob_get_clean();
$this->assertStringContainsString( 'value="Private: Secret (ID: ' . $id . ')"', $html );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Call to an undefined method test_FrmPostDropdownLabels::assertStringContainsString()


The method you are trying to call is not defined, which can result in a fatal error.

@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 11, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve at 3acba6b with one non-blocking note. This is a re-review of the whole PR (my Request Changes was at 89757f3). The new commit 3acba6b fixes the blocking item and the two non-blocking ones.

Earlier items

  1. Page search by prefilled label or ID: fixed. get_page_search_results() strips a trailing (ID: n) and also matches an all-digit term against ID. Both halves are covered by test_page_search_matches_prefilled_label_and_id, and I mutation-checked it: with the suffix strip removed the Saved Listings (ID: n) term fails, and with the digit branch removed the n term fails.
  2. page_dropdown_label() with no caller: fixed. It is gone, and the dropdown test now goes through wp_pages_dropdown().
  3. Private: / Protected: prefix dropped on the selected value: fixed. get_the_title( $post ) feeds the label, and the test asserts Private: Secret (ID: n).

Checked

  • Read the full diff again. The new SQL group keeps post_status = publish and post_type as ANDed conditions: with a draft page, a post and a page all titled ... 24, searching 24 against type page returned only the published page, and a post's ID returned nothing. The label goes through esc_html / esc_attr at the call sites, and the test covers a <script> title.
  • Live, in a Playground preview env (Lite at 3acba6b, 52 filler pages, two pages titled "Pricing", one untitled, one with a 190-character title, one private), in Form settings > Confirmation > Show Page Content:
    • "Pric" lists Pricing (ID: 62) and Pricing (ID: 63), so duplicate titles are told apart.
    • 64 lists (no title) (ID: 64), and "A very long" lists the full long title with no truncation in the autocomplete.
    • A prefilled Pricing (ID: 63) still lists both Pricing pages, and picking one sets the input to Pricing (ID: 63) with the hidden value 63.

Autocomplete results with IDs

Non-blocking

  • Editing the prefilled label by backspacing into the suffix finds nothing until it is fully removed. The strip only matches a complete (ID: n), so Pricing (ID: 6 is searched as a literal title and returns "No items found." (also Pricing (ID:, Pricing (). Select-all and retype, and deleting the whole suffix, both work. A looser pattern in get_page_search_results() that also drops an unfinished trailing (ID... would cover it; a test line with Saved Listings (ID: would pin it.

Tests run: phpunit -c <9.x config> tests/phpunit/misc/test_FrmPostDropdownLabels.php at 3acba6b in the wordpress-develop harness (PHP 8.4, PR copied in) → OK (6 tests, 22 assertions). CI skipped PHPUnit, PHPCS and PHPStan on this draft, so that local run is the only execution.

CI note: the DeepSource: PHP check is red, with its inline comments saying assertSame, assertStringContainsString, assertLessThan and factory() are undefined on test_FrmPostDropdownLabels. Those are inherited from the WP/PHPUnit test case and the file runs green, so they look like false positives from DeepSource not resolving the base class. Someone with DeepSource access should confirm and dismiss them before merge.

Not covered

  • Saving the action and reloading to see the prefilled Title (ID: n) in the browser (the save click hit an ambiguous button in my driver); the render of that value is covered by the PHPUnit test only.
  • The plain dropdown (50 pages or fewer) and the long-title truncation in a browser, and the gated-content selector (Pro companion formidable-pro#6973). These are covered by the PHPUnit tests only.
  • code-review, security-review and simplify were not run.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 11, 2026
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 11, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve. The non-blocking note from my last review is fixed at 84cdf0f, and the merge of master after it is clean. I found nothing new.

  • Backspacing into the suffix now works: the strip in get_page_search_results() also drops an unfinished trailing (, (I, (ID, (ID: and (ID: 6. I ran the regex over 19 inputs: every partial suffix and Pricing (ID:63 reduce to Pricing; real parentheticals such as Pricing (Inc.), (Intro) and (IDEA are left alone. The test now pins Saved Listings (ID: 6, (ID: , (ID, (I and (.
  • The test catches the old code: with the old \(ID: \d+\) regex put back, test_page_search_matches_prefilled_label_and_id fails; with the new one it passes.
  • Merge is clean: git show --remerge-diff on d7d804b is empty. The PR's own diff is still the 4 files I reviewed (FrmSettingsController, FrmAppHelper, FrmGatedContentAction, the test).
  • phpcs --standard=phpcs.xml over those 4 files is clean.

Tests run: phpunit tests/phpunit/misc/test_FrmPostDropdownLabels.php at d7d804b in the wordpress-develop harness (PR copied in) → OK (6 tests, 27 assertions). Wider --filter 'FrmSettings|FrmAppHelper|FrmPostDropdown|FrmGatedContent' → OK (76 tests, 355 assertions). CI skipped PHPUnit and PHPCS on this draft, so these local runs are the only execution.

Not exercised: the autocomplete input in the admin UI after this commit (the search logic ran against the real DB via PHPUnit, the typing flow did not), the Pro companion formidable-pro#6973, and the three review skills. The DeepSource: PHP check is still red with the same undefined-assert comments on the test file; they look like false positives from the base class not resolving, and someone with DeepSource access should dismiss them before merge.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 11, 2026
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 12, 2026
@franky-the-going-merry

Copy link
Copy Markdown
Contributor

franky-review was re-added at 18:25Z, but the head is still d7d804b, the commit my Approve (2026-11-11 21:24Z) covers, and there are no new commits since. The PR is still mergeable with no conflicts, so I did not repeat the review. The Approve stands. Removing the labels. Add franky-review again after the next push.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 12, 2026
Crabcyborg and others added 2 commits November 16, 2026 10:45
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 16, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve at 79a98a2. My Approve was at d7d804b; the head has since moved by two merges of master (0984677, 79a98a2), so this is a fresh verdict at the new head, not a relabel.

  • PR's own change is untouched: git show --remerge-diff is empty for both merges (clean). The PR diff is still the same 4 files. FrmSettingsController, FrmGatedContentAction and the test are byte-identical to d7d804b. The only change to FrmAppHelper.php since then is master's own hunks (long-key duplicate fix, styler colour parsing); none of them touch get_post_dropdown_label() or wp_pages_dropdown().
  • Nothing new found on the PR's code.

Tests run: phpunit -c phpunit9.xml tests/phpunit/misc/test_FrmPostDropdownLabels.php at 79a98a2 in the wordpress-develop harness (PHP 8.4, PR copied in) → OK (6 tests, 27 assertions). Wider --filter 'FrmSettings|FrmAppHelper|FrmPostDropdown|FrmGatedContent' → OK (77 tests, 359 assertions). CI skipped PHPUnit and PHPCS on this draft, so this local run is the only execution.

Not exercised: the autocomplete input in the admin UI at this head (the earlier live pass was at 3acba6b; the search logic ran against the real DB via PHPUnit), PHPCS at this head, the Pro companion formidable-pro#6973, and the three review skills. The DeepSource: PHP red check is the same undefined-assert false positive noted before; someone with DeepSource access should dismiss it before merge.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 16, 2026
@Crabcyborg Crabcyborg modified the milestones: 7.1, 7.2 Nov 17, 2026
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