From a16458f48f66aacfb72b00d01cce686de6e53180 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Wed, 13 Nov 2024 16:23:07 -0500 Subject: [PATCH] Revert applyFiltersFromModel change (#1126) Reverts changes to original behavior - too many problems. Related: #1222 #927 was originally intended to solve the issue logged in #950 where if you hide a field by default, and then want to unhide it dynamically in filterFields() it does not get saved because disabled and hidden fields are skipped by default in Form->getSaveData(); so the proposed fix was to apply model filtering logic immediately before processing the save data; however that caused issues (#1036) because the model was no longer populated the same way when calling filterFields() at that point in the request and the filterFields() method could be called multiple times. The solution to the original issue would have been to use the client side Trigger API instead; and potentially we could have solved the other issue by looking at how we're populating the model before calling filterFields() but as this functionality isn't well tested we'll just revert for now. The second change being reverted is #1099 which was an attempt to solve an issue encountered by someone that was caused by the method being called multiple times. --- modules/backend/widgets/Form.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index 59ec24e033..ecb078c4d6 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -354,7 +354,7 @@ public function setFormValues($data = null) public function onRefresh() { $result = []; - $saveData = $this->getSaveData(true); + $saveData = $this->getSaveData(); /** * @event backend.form.beforeRefresh @@ -1172,10 +1172,9 @@ protected function showFieldLabels($field) /** * Returns post data from a submitted form. */ - public function getSaveData(bool $includeAllFields = false): array + public function getSaveData(): array { $this->defineFormFields(); - $this->applyFiltersFromModel(); $result = []; @@ -1194,7 +1193,7 @@ public function getSaveData(bool $includeAllFields = false): array /* * Disabled and hidden should be omitted from data set */ - if (!$includeAllFields && ($field->disabled || $field->hidden)) { + if ($field->disabled || $field->hidden) { continue; }