Repository navigation
Add File Upload fields to PDF conditional logic - #1961
Merged
jakejackson1 merged 3 commits intoOct 26, 2026
Merged
Conversation
Gravity Forms leaves File Upload fields out of its conditional logic field list, since there is nothing to compare until the entry is saved. PDF conditional logic is always evaluated against a saved entry, so offer single and multi-file uploads with "is / is not Empty" through the same post-submission field map the Unique ID perk already uses. Multi-file uploads are stored as a JSON list, and Gravity Forms can save an empty "[]" (e.g. when every existing file fails validation), which a plain string comparison treats as not empty. The rule source value for File Upload fields is now converted to an array of file URLs with GF_Field_FileUpload::to_array(), so Gravity Forms' own array matching decides emptiness. The options map now carries choices per field type, which also lets PHPStan drop a baseline entry. Resolves #1619 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Coverage report for commit: 797bee0 Summary - Lines: 93.30% | Methods: 88.89% | Branches: 82.27%
🤖 Jest coverage report |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
|
Coverage report for commit: 797bee0 Summary - Lines: 88.31% | Methods: 95.13%
🤖 PHPUnit coverage report |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
… test Image Hopper's fields (image_hopper / image_hopper_post) extend GF_Field_FileUpload under their own type, and their get_input_type() only reports "fileupload" during submission and a few other requests, not on the PDF settings screen. The field list now also takes every registered field type whose class extends GF_Field_FileUpload, read from GF_Fields::get_all(), so GFAPI::get_fields_by_type() still walks nested fields. GF_Field_FileUpload::to_array() only exists since Gravity Forms 2.10, while the plugin still supports 2.5+, and the source-value filter runs on every rule check. The stored value is now decoded inline instead: empty and "[]" both give an empty list. The Playwright spec picks each File Upload field in the PDF conditional logic UI, checks the is / is not operators and "Empty" value, saves, reloads to confirm the rule persisted, and checks only the entry with a file gets a PDF link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Another gform_rule_source_value callback can run first and return an array, and json_decode() throws a TypeError on one under PHP 8. The filter runs on every Gravity Forms conditional logic check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks
gravitypdf-bot
added a commit
that referenced
this pull request
Oct 26, 2026
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>
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.
Summary
PDF conditional logic had no way to check whether a File Upload field holds a file: Gravity Forms leaves File Upload fields out of its conditional logic field list. This PR 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.is/is notand an "Empty" value[]is treated as empty[]entriestests/playwright/core/pdf-settings/file-upload-conditional-logic.spec.tsfor the settings UI, saving and the entry list PDF linkResolves #1619
Try it
Expected:
''and'[]'printconditional_logic, the entry with a file printsPDF available. Ondevelopmentthe'[]'entry printsPDF available.Test plan
is/is notand an "Empty" value, an "is not Empty" rule survives save and reload, and only the entry with a file gets a "View PDF" linkMore info
Root cause. Gravity Forms' admin JS only lists field types from its own conditional logic whitelist, which excludes
fileupload(there's nothing to compare on the front end before upload). Gravity PDF already had a mechanism for exactly this case:Helper_Data::get_conditional_logic_options()keeps a map of "post-submission" field types (until now only the Gravity Wiz Unique ID field), which is passed to the admin page asgfpdf_extra_conditional_logic_optionsand injected through thegform_conditional_logic_fields/gform_conditional_logic_operators/gform_conditional_logic_values_inputJS filters inhandlePDFConditionalLogic.js.fileuploadis added to that map withis/isnotoperators and a singleEmpty('') choice, so the value input renders as a dropdown instead of a free-text box. Field types whose registered class extendsGF_Field_FileUpload(fromGF_Fields::get_all()) are also passed toGFAPI::get_fields_by_type()and use thefileuploadentry, so Image Hopper'simage_hopper/image_hopper_postfields show up (theirget_input_type()only saysfileuploadduring submission and a few other requests, not on this screen), and nested fields are still walked. The map entries are now merged in whole, so a type can carrychoices(this also removes a PHPStan baseline entry for the oldrgars()call). No JS changes were needed.Evaluation. PDF conditional logic runs through
GFCommon::evaluate_conditional_logic(). For a File Upload field the source value is the raw entry value: a URL (single) or a JSON list (multi).''already worked withis '', but multi-file fields can be saved as"[]"(e.g.get_parsed_list_of_files()when no existing file matches), which a string comparison treats as not empty.Controller_Form_Settings::conditional_logic_set_rule_source_value()(ongform_rule_source_value) now turns File Upload values into a list of file URLs (empty and"[]"give an empty list, other JSON is decoded, a plain URL becomes a one-item list), and Gravity Forms' own array matching handlesis ''(every value empty, so an empty list matches) andisnot ''(at least one file). The value is decoded inline rather than withGF_Field_FileUpload::to_array(), which only exists since Gravity Forms 2.10 while the plugin still allows 2.5+. A value that's already an array (from another plugin'sgform_rule_source_valuecallback) is passed through untouched, sincejson_decode()throws aTypeErroron an array under PHP 8 and this filter runs on every Gravity Forms conditional-logic check. As a side benefit the entry-meta option list is no longer built when no entry is passed.Checks run locally
development's controller (the[]case) and pass with the fixpdf-settings.spec.tsandconditional-logic-pdf.spec.tson a fresh e2e env, all pass. Without the fix the new spec times out selecting the File Upload field (did not find some options)[]case is left to PHPUnittools/phpcs/config.xmland PHP compatibility) and ESLint on the changed files: cleancomposer phpstan): no errorsThe 6.18.0 backport is #1968.
🤖 Generated with AI