Fix: Preserve conditional field values when hidden (issue #7475)#7484
Fix: Preserve conditional field values when hidden (issue #7475)#7484faisalahammad wants to merge 2 commits intopods-framework:mainfrom
Conversation
This commit adds a new 'Save Value When Hidden' option for fields with conditional logic. Problem: When a conditional field's parent condition is set to false, child field values get reset to null (Issue pods-framework#7475). Solution: - Added 'conditional_logic_save_value' boolean option in Field.php - Modified PodsAPI.php to check this option before clearing hidden field values - When enabled, the field value is preserved even when the field is not visible Fixes pods-framework#7475
PR Summary
|
|
@faisalahammad hey, just checking in on this -- did you intend to close the PR? |
…ork#7475) Added 'conditional_logic_save_value' option to field configuration that allows preserving field values when the field is hidden by conditional logic. Changes: - Field.php: Added new 'conditional_logic_save_value' boolean option - PodsMeta.php: Skip adding hidden fields to save data when option is enabled This prevents the empty default value from overwriting existing database values when conditional logic hides a field during form submission.
|
Sorry, @sclark3-godaddy |
|
Looks good, thanks! Merged via #7485 |
Summary
Fixes #7475 - Adds an option to preserve conditional field values when the field is hidden by conditional logic.
Problem
When a field is hidden by conditional logic, saving the form clears the field's value in the database. This happens because:
PodsMeta.phpinitializes ALL fields with an empty string default$_POSTSolution
Added a new field option "Save Value When Hidden" (
conditional_logic_save_value) that:Changes
src/Pods/Admin/Config/Field.phpAdded new
conditional_logic_save_valueboolean option to field configuration.classes/PodsMeta.phpBefore:
After:
classes/PodsAPI.phpBefore:
After:
Testing
Checklist
Screen Recording
Before: https://videos.faisalahammad.com/recordings/hR9KDdIgMfSUNC1nh3hm
After: https://videos.faisalahammad.com/recordings/P91zwf3QD774GdGqLovP
Plugin Zip
pods-issue-7475-save-conditional-value.zip