old value laravel select code example
Example 1: laravel old value for select option
@foreach($services as $service)
@if (old('category') == $service->id)
<option value="{{ $service->id }}" selected>{{ $service->title }}</option>
@else
<option value="{{ $service->id }}">{{ $service->title }}</option>
@endif
@endforeach
Example 2: laravel select default old value
<option value="{{ $key }}" {{ (Input::old("title") == $key ? "selected":"") }}>{{ $val }}</option>
Example 3: laravel form old value array
{{ var_dump(old('field.0')) }}
<form method="post" action="">
{!! csrf_field() !!}
<input type="text" name="field[]" value="{{ old('field.0') }}" />
<input type="text" name="field[]" value="{{ old('field.1') }}" />
<input type="text" name="field[]" value="{{ old('field.2') }}" />
<input type="submit" name="submit" value="Submit" />
</form>