From edcd899a794caa78e2489a18987d59fd7acf83f2 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Tue, 6 Jun 2017 20:44:15 +1000 Subject: [PATCH] Base getLoadValue to look at form field first Fixes https://github.com/octobercms/october/pull/2663 Adding to build 420+ because this might cause some issues, although it shouldn't. Hoping we don't ever have to roll this back because it fixes another inconsistency when using the model `filterFields` method... some will change values via $field->value (field accessor) and others will change via $this->value ($model accessor). This now puts the field accessor at a consistent priority (first) while retaining the fallback to model. --- modules/backend/classes/FormWidgetBase.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/backend/classes/FormWidgetBase.php b/modules/backend/classes/FormWidgetBase.php index a7eb5636b..a9616e32f 100644 --- a/modules/backend/classes/FormWidgetBase.php +++ b/modules/backend/classes/FormWidgetBase.php @@ -123,6 +123,10 @@ abstract class FormWidgetBase extends WidgetBase */ public function getLoadValue() { + if ($this->formField->value !== null) { + return $this->formField->value; + } + $defaultValue = !$this->model->exists ? $this->formField->getDefaultFromData($this->data ?: $this->model) : null;