Skip to content

Commit

Permalink
Revert applyFiltersFromModel change (#1126)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mjauvin authored Nov 13, 2024
1 parent 225457a commit a16458f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions modules/backend/widgets/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function setFormValues($data = null)
public function onRefresh()
{
$result = [];
$saveData = $this->getSaveData(true);
$saveData = $this->getSaveData();

/**
* @event backend.form.beforeRefresh
Expand Down Expand Up @@ -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 = [];

Expand All @@ -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;
}

Expand Down

0 comments on commit a16458f

Please sign in to comment.