From fc025c08763732acb7e570365d57a75d719a9aa2 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 20 Mar 2013 23:53:57 +0100 Subject: [PATCH] Prefer old input data over form field values. --- FormBuilder.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/FormBuilder.php b/FormBuilder.php index 34ff6dc..374d453 100644 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -658,19 +658,23 @@ class FormBuilder { /** * Get the value that should be assigned to the field. * + * This returns either old input for this field, the + * value passed to this method or the equally-named attribute of the + * current model instance (in this order of precedence). + * * @param string $name * @param string $value * @return string */ protected function getValueAttribute($name, $value) { - if ( ! is_null($value)) return $value; - if (isset($this->session) and $this->session->hasOldInput($name)) { return $this->session->getOldInput($name); } + if ( ! is_null($value)) return $value; + if (isset($this->model) and isset($this->model[$name])) { return $this->model[$name];