Skip to content

Add File Upload fields to PDF conditional logic (6.18.0) - #1968

Merged
gravitypdf-bot merged 1 commit into
hot-patch-6.18.0from
fix-1619-file-upload-conditional-logic-6.18
Oct 26, 2026
Merged

gravitypdf-bot merged 1 commit into
hot-patch-6.18.0from
fix-1619-file-upload-conditional-logic-6.18

Conversation

@gravitypdf-bot

Copy link
Copy Markdown
Contributor

Summary

Backport of #1961 to 6.18.0. PDF conditional logic had no way to check whether a File Upload field holds a file, because Gravity Forms leaves File Upload fields out of its conditional logic field list. This adds single and multi-file File Upload fields to the PDF conditional logic UI with "is / is not Empty", and makes an empty multi-file list ([]) count as empty.

  • File Upload fields now appear in the PDF conditional logic field list, with is / is not and an "Empty" value
  • Fields built on the File Upload field, such as Image Hopper, are listed too
  • Multi-file values are compared file by file, so an entry saved as [] is treated as empty
  • PHPUnit coverage for the field list, a File Upload subclass, and single, multi, empty and [] entries
  • CHANGELOG line under 6.18.0 (🎉 Feature)

Try it

gh pr checkout fix-1619-file-upload-conditional-logic-6.18 --repo GravityPDF/gravity-pdf
vendor/bin/phpunit --filter Test_Form_Settings

Or by hand: add a multi-file File Upload field to a form, then in a PDF's settings enable Conditional Logic, pick the upload field, choose "is not" and "Empty", and save. Submit one entry with a file and one without: only the first gets the PDF in the entry list.

Test plan

  • File Upload fields are offered in PDF conditional logic with is / is not and "Empty"
  • A saved "is not Empty" rule persists after reload
  • An entry with a file gets the PDF; an entry without one doesn't
  • With Image Hopper active, its fields appear in the field list
  • Test_Form_Settings passes
More info

Same source change as #1961 (both files applied cleanly; Controller_Form_Settings.php was identical on both branches, and Helper_Data.php differs only in unrelated methods). Left on development: the Playwright spec (no E2E on hot-patch branches) and the PHPStan baseline edit (6.18 has no PHPStan).

The new PHPUnit tests go at the end of 6.18's tests/phpunit/unit-tests/test-form-settings.php. development's tests create forms with gf_factory(), which 6.18 doesn't have, so they use GFAPI::add_form() instead; the assertions are unchanged.

Compatibility: GFAPI::get_field() and GF_Fields::get_all() are both older than the 2.5 Gravity Forms floor, and the value is decoded inline rather than with GF_Field_FileUpload::to_array() (Gravity Forms 2.10+). The rule evaluation relies on the gform_rule_source_value filter, which Gravity Forms added in 2.6.2, so on 2.5–2.6.1 the fields are listed but [] isn't treated as empty, the same limit the existing entry-meta rules already have. No PHP 7.4+ syntax.

Checks run locally on the 6.18 build (own test DB): Test_Form_Settings 32 tests passing. With the two source files reverted to hot-patch-6.18.0, the new tests fail (2 errors, 2 failures). PHPCS (phpcs.xml.dist and phpcompat.xml.dist) clean on the changed files. The full suite and multisite weren't run locally; CI covers them. Not checked with the real Image Hopper plugin.

🤖 Generated with AI

Backport of #1961: source and PHPUnit only. The Playwright spec and PHPStan baseline change stay on development.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gravitypdf-bot
gravitypdf-bot merged commit b8b352b into hot-patch-6.18.0 Oct 26, 2026
13 checks passed
@gravitypdf-bot
gravitypdf-bot deleted the fix-1619-file-upload-conditional-logic-6.18 branch October 26, 2026 07:01
@gravitypdf-bot gravitypdf-bot mentioned this pull request Oct 26, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant