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

edoc's avatar
Level 24

Retrieve all old inputs

Hey guys.Is it possible to retrieve every old input in one go after validations fail and get redirected back?Or, do I have to get it one by one like this?

old('foo')
old('bar')
0 likes
5 replies
SaeedPrez's avatar
Level 50

Try this..

$old = session()->getOldInput();
8 likes
edoc's avatar
Level 24

@SaeedPrez Thanks for taking time to answer my question.I tried that but I got this error.Do you know why

htmlentities() expects parameter 1 to be string, array given

Do you have any ideas as to how else we can do this?

SaeedPrez's avatar

@edoc the code I gave you returns an array with the old input data. This means you can't treat it as a string and do something like {{ $old }} or whatever, you have to treat is as an array.

Snapey's avatar

explain what you are trying to do with this old data?

edoc's avatar
Level 24

@SaeedPrez @Snapey

I tried to pass the data to a Vue component I figured this out Thanks guys

 <training-request-form :old="{{ json_encode(Session::getOldInput()) }}"></training-request-form>
5 likes

Please or to participate in this conversation.