Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jonnybarnes's avatar

On a validation error, my form has no old input data?

My controller has the following validation code:

$validator = Validator::make(
    $request->all(),
    ['photo' => 'photosize'],
    ['photosize' => 'At least one uploaded file exceeds size limit of 5MB']
);
if ($validator->fails()) {
    return redirect('/admin/note/new')
        ->withErrors($validator)
        ->withInput();
}

And in my blade template for the form two of the inputs contain name="foo" value="{{ old('foo') }}". The form however is blank. What am I missing?

0 likes
7 replies
jonnybarnes's avatar

Using laravel debug bar I can see that session_attributes => _old_input contains the correct information, it seems the old() helper isn’t working though.

ABDELRHMAN's avatar
Level 5

try this

<input type="text" value=" { { old('foo') } } " name="foo">

remove the space between the curly braces

3 likes
Snapey's avatar

Double space your { { } } so that it shows in the forum, else we can't help. Click the pencil and edit your post.

ACH's avatar

Similar issue here. The following input does not display the old value after error:

<x-jet-input id="subscrFile" class="block mt-1 w-full" type="file" name="subscrFile" :value="old('subscrFile')" autofocus autocomplete="subscrFile" />

Adding {{}} around old() gives error message syntax error, unexpected token "<"

tykus's avatar

@ACH maybe opening your own thread rather than resurrecting a 7 years old one would be better???

Snapey's avatar

@ACH you cannot repopulate file input fields. This is an HTML security feature, not Laravel or old() related

ACH's avatar

@Snapey OK, but if I go back, in the browser (Chrome), then my chosen files are displayed. Only when I trigger a validation error the file name fields get cleared?

Please or to participate in this conversation.