From 110a2ec243e75ebc433999e320f71b73814b0e65 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@enhancesoft.com> Date: Thu, 12 Mar 2015 15:02:35 +0000 Subject: [PATCH] forms: use uasort instead of usort Preserve the fields indexed keys Only sort the fields once, after adding missing fields --- include/class.dynamic_forms.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index fbdb14229..c97739963 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -950,12 +950,14 @@ class DynamicFormEntry extends VerySimpleModel { $a->save(); } - // Sort the form the way it is declared to be sorted - if ($this->_fields) - usort($this->_fields, - function($a, $b) { - return $a->get('sort') - $b->get('sort'); - }); + } + + // Sort the form the way it is declared to be sorted + if ($this->_fields) { + uasort($this->_fields, + function($a, $b) { + return $a->get('sort') - $b->get('sort'); + }); } } -- GitLab