From fc025c08763732acb7e570365d57a75d719a9aa2 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 20 Mar 2013 23:53:57 +0100 Subject: [PATCH 1/3] 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]; From 560af380fcff34cc08baab08be26268ced4a324f Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 20 Mar 2013 23:55:47 +0100 Subject: [PATCH 2/3] Don't fetch old input for unnamed fields. This is the proper fix for the underlying problem of #638. --- FormBuilder.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/FormBuilder.php b/FormBuilder.php index 374d453..d317e44 100644 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -658,7 +658,7 @@ class FormBuilder { /** * Get the value that should be assigned to the field. * - * This returns either old input for this field, the + * If a name is given, 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). * @@ -668,6 +668,8 @@ class FormBuilder { */ protected function getValueAttribute($name, $value) { + if (is_null($name)) return $value; + if (isset($this->session) and $this->session->hasOldInput($name)) { return $this->session->getOldInput($name); From 793787e8a6a6da2381d97328cbdc0cf9cf939af6 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 20 Mar 2013 23:56:49 +0100 Subject: [PATCH 3/3] Don't hardcode default value for submit buttons. --- FormBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FormBuilder.php b/FormBuilder.php index d317e44..746e081 100644 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -497,7 +497,7 @@ class FormBuilder { * @param array $options * @return string */ - public function submit($value = 'Submit', $options = array()) + public function submit($value = null, $options = array()) { return $this->input('submit', null, $value, $options); }