From 3809fee0a7bb8fb5e0b1e063cb607afe354d9b3e Mon Sep 17 00:00:00 2001 From: Brad Estey Date: Wed, 31 Jul 2013 16:37:51 -0400 Subject: [PATCH 1/2] Fixed FormBuilder selectMonth. mktime() fails on the 31st of a month when the day is null. See http://www.php.net/manual/en/function.mktime.php#99707 --- FormBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FormBuilder.php b/FormBuilder.php index d406376..868da9c 100755 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -455,7 +455,7 @@ class FormBuilder { foreach (range(1, 12) as $month) { - $months[$month] = strftime('%B', mktime(0, 0, 0, $month)); + $months[$month] = strftime('%B', mktime(0, 0, 0, $month, 1)); } return $this->select($name, $months, $selected, $options); From fdb891e180242578a04433229d5fc020ee4605d5 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 1 Aug 2013 08:25:31 -0500 Subject: [PATCH 2/2] Fix form builder with model binding. --- FormBuilder.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/FormBuilder.php b/FormBuilder.php index 868da9c..fd98299 100755 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -618,7 +618,7 @@ class FormBuilder { { if ( ! $this->oldInputIsEmpty() and is_null($this->old($name))) return false; - if (is_null($this->old($name))) return $checked; + if ($this->missingOldAndModel($name)) return $checked; return (bool) $this->getValueAttribute($name); } @@ -633,11 +633,22 @@ class FormBuilder { */ protected function getRadioCheckedState($name, $value, $checked) { - if (is_null($this->old($name))) return $checked; + if ($this->missingOldAndModel($name)) return $checked; return $this->getValueAttribute($name) == $value; } + /** + * Determine if old input or model input exists for a key. + * + * @param string $name + * @return bool + */ + protected function missingOldAndModel($name) + { + return (is_null($this->old($name)) and is_null($this->getModelValueAttribute($name))); + } + /** * Create a HTML reset input element. *