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.
This commit is contained in:
Samuel Georges 2017-06-06 20:44:15 +10:00
parent f7d0d394f5
commit edcd899a79

View File

@ -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;