diff --git a/FormBuilder.php b/FormBuilder.php index c563932..d7f2f7b 100644 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -727,9 +727,27 @@ class FormBuilder { if ( ! is_null($value)) return $value; if (isset($this->model) and isset($this->model[$name])) + { + return $this->getModelValueAttribute($name); + } + } + + /** + * Get the model value that should be assigned to the field. + * + * @param string $name + * @return string + */ + protected function getModelValueAttribute($name) + { + if (is_object($this->model)) { return object_get($this->model, $name); } + elseif (is_array($this->model)) + { + return array_get($this->model, $name); + } } /**