search

Home  >  Q&A  >  body text

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

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

大家讲道理大家讲道理2799 days ago477

reply all(4)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 16:54:06

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

    if (! function_exists('old')) {
        /**
    1. old($key = null, $default = null)

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

      }

    In fact, this also points to request

    reply
    0
  • 阿神

    阿神2017-05-16 16:54:06

    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.

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 16:54:06

    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.

    reply
    0
  • 某草草

    某草草2017-05-16 16:54:06

    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') }}" />

    reply
    0
  • Cancelreply