Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the old method in laravel

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "how to use the old method in laravel", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use the old method in laravel" article.

In laravel, the old () method is used to extract the information from session with the syntax "value=" {{old ('name')}} "; when the form submission fails, laravel will flash the data entered by the user into an one-time session, and old can retrieve the flash data from it.

This article operating environment: Windows10 system, Laravel6 version, Dell G3 computer.

How to use old method in laravel

Because error messages flash into session, the old function fetches the information from session

Value= "{{old ('name')}}"

When a user fails to submit a form, laravel automatically flash the user's input data into an one-time session (this data will be lost as soon as it is refreshed, so it is called one-time data). Then old ('name') can take out the flash data in the session and avoid letting the user re-enter it.

Using old (), you can take the last submitted data from the one-time session and hang it on the DOM element, thus preventing the user from re-entering it.

Examples are as follows:

The traditional submission form page will be refreshed and the contents of the input box will be lost. Laravel

Better user experience solution withInput () + old () session

Laravel automatically stores the data entered by the user into an one-time session. Function

Using old (), you can take the last submitted data from the one-time session and hang it on the DOM element, thus avoiding the user's new input. Input

Using withInput (), in conjunction with the with method, you can write the parameters you want to return to session. The blade template can extract the value from the session to make some logical judgments. It

Return redirect ()-> back ()-> withInput ()-> with (['error'= >' failed to register, incorrect SMS verification code', 'page'= >' phone'])

Blade template old () assignment function written as io

The above is about the content of this article on "how to use the old method in laravel". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report