What does the old() method in laravel template do?
大家讲道理
大家讲道理 2017-05-16 16:52:06
0
4
457

What does the old() method in laravel template do?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(4)
巴扎黑

You can use phpstorm and then command+b to view its source code,

if (! function_exists('old')) {
    /**
    • Retrieve an old input item.
      *

    • @param string $key

    • @param mixed $default

    • @return mixed
      */

    1. old($key = null, $default = null)

         {
             return app('request')->old($key, $default);
         }

      }

    In fact, this also points to request

    阿神

    Can be used to receive old input data returned by the validate object. In this way, users can know what data they filled in before when verification fails.

    仅有的幸福

    For example, when posting to an address and verifying data errors, you have to return to the previous page. For a better user experience, the filled-in information will be saved in the flash session and displayed on the previous page.
    This way users won’t make mistakes after painstakingly filling in a lot of form data, and then go back and refill it.

    某草草

    Documentation: http://laravel-china.org/docs...

    Old input data
    When the user fails to submit the form, laravel will automatically flash the user's input data into a one-time session (this data will be lost as soon as it is refreshed, so it is called one-time data). Then old('input_name') can take out the flash memory data in the session, thereby preventing the user from re-entering.

    <input type="text" name="input_name" value="{{ old('input_name') }}" />
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template