Merge pull request #642 from franzliedke/patch-4

Improvements for form values
This commit is contained in:
Taylor Otwell committed 2013-03-25 14:10:58 -07:00
commit 338c6c26cc
1 file changed
+8 -2
+8 -2
View File
@@ -512,7 +512,7 @@ class FormBuilder {
* @param array $options * @param array $options
* @return string * @return string
*/ */
public function submit($value = 'Submit', $options = array()) public function submit($value = null, $options = array())
{ {
return $this->input('submit', null, $value, $options); return $this->input('submit', null, $value, $options);
} }
@@ -673,19 +673,25 @@ class FormBuilder {
/** /**
* Get the value that should be assigned to the field. * Get the value that should be assigned to the field.
* *
* 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).
*
* @param string $name * @param string $name
* @param string $value * @param string $value
* @return string * @return string
*/ */
protected function getValueAttribute($name, $value = null) protected function getValueAttribute($name, $value = null)
{ {
if ( ! is_null($value)) return $value; if (is_null($name)) return $value;
if (isset($this->session) and $this->session->hasOldInput($name)) if (isset($this->session) and $this->session->hasOldInput($name))
{ {
return $this->session->getOldInput($name); return $this->session->getOldInput($name);
} }
if ( ! is_null($value)) return $value;
if (isset($this->model) and isset($this->model[$name])) if (isset($this->model) and isset($this->model[$name]))
{ {
return $this->model[$name]; return $this->model[$name];