Reputation: 4944
How I can use Input::old() in edit page, when value is
{{ $user->name }}
But, if name is invalid¹, or something, how I can get the Input::old() and override {{ $user->name }} ?
For example:
<input type="text" id="name" name="name" placeholder="Nome" class='span12' value="{{ $user->name }}" />
¹ fail in validation test
Upvotes: 0
Views: 580
Reputation: 569
use this
<input type="text" id="name" name="name" placeholder="Nome" class='span12' value="{{old('name', $user->name) }}" />
and for checkbox
<input id="main" class="form-check-inline"
type="checkbox" name="position" {{old('position',$user->position)?'checked':''}}>
Upvotes: 1
Reputation: 27941
{{ Form::text(
'name',
Input::old('name', $user->name),
array('class' => 'span12','placeholder' => 'Name')
)}}
Upvotes: 2
Reputation: 1923
My first/quick guess is that you've not called flash() ahead of time, which is needed to place the input values into the session in the first place...
Input::flash();
http://laravel.com/docs/input#old-input
Upvotes: 1
Reputation: 4944
I don't know if I'm correctly, but in Developer Api, have this:
public static function old($key = null, $default = null)
{
return array_get(Session::get(Input::old_input, array()), $key, $default);
}
So, I can use:
{{ Input::old('name', $user->name) }}
Right?
So, I think is that. If I not correctly, please tell me.
Anyway, Thanks Guys.
Upvotes: 1