当前位置:网站首页>How to implicitly pass values when transferring forms

How to implicitly pass values when transferring forms

2022-07-04 16:45:00 Struggling young man

When the form is transferred , How to implicitly pass the value .

Case description

  1. When modifying form elements , When you click the Modify button , Need to send out get request , So that it can be displayed in the form that pops up later ( Good user experience ).
  2. The request from the foreground to the backend is get request , And pass it to a value id Used to query the corresponding tables in the database ,id For all fields of this value and return to the foreground , The foreground will render the required fields to the page .
  3. When the user makes modifications in the pop-up box , Then submit the data to the background interface , After the background interface receives the data , Execute database statement , Complete data update .
difficulty

The problem to be solved appears in the second step , That is, data modification , And send the data back to the background . And here comes the question , How does the database know which data you want to modify ? Your pop-up box form What the form submits is only the modified value , Not given id ah .

This is the time , In the first step , We have found all the attributes in the data , Why not send a message id Well ?

what ? You said you didn't want users to modify id( Primary key )? Oh , It's easy to do . We can add another label to the form , And the value is preset , That is, you need to modify the database corresponding to that data id( Primary key ), But we don't show it to users , We hide it . Ah , Just play !

When submitting data at this time , There is id( Primary key ) 了 , Problem solving .

Here is a solution for you , If there is a better way , Welcome to leave a message .

原网站

版权声明
本文为[Struggling young man]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207041455475335.html