1. display controller variables in the view.
Assign a value to the variable in the control, such as $ this-> info_user = $ user, which can be directly used in the view.
2. Use the volist tag for HTML display Arrays
<Volist name = "info_user" id = "VO">
{$ VO. Username} {$ VO. Email} can use the key-value pairs in the array.
3. Hide button <button type = "Submit" style = "display: none"> submit changes </button>
4. Add JS Code to view HTML. Note that the introduction of JS Code must be declared in the head label!
<block name="head"> <script type="text/javascript"> function writable(){ alert("5"); } </script></block>
Or
<block name="head"> <script type="text/javascript" src="/Public/js/Contribute/index.js"></script></block>
In this way, functions in javascript can be used.
5. Use JavaScript Functions to modify the readonly attribute of HTML tags.
VaR username = Document. getelementsbyid ("1 ");
Username. readonly = "";
// Set the submit button to visible display: None --> display: inline or default
VaR submit = Document. getelementsbyname ("Submit ");
Submit [0]. style. Display = ""; visible in inline by default
6. Differences between getelementsbyname and getelementbyid:
VaR username = Document. getelementsbyname ("username"); obtain multiple objects named username and the result is an array. Modify the attributes in the username [I] mode during use;
VaR username = Document. getelementsbyid ("1"); get a specific object. Use it directly.
7. Jump to the page
$ This-> success ('Modified successfully', '/user/userinfo ');
$ This-> error ('modification failed', '/user/userinfo ');
8. update the database using the data submitted by post
// If it is not submitted by post, an error is reported directly.
If (! Is_post) Halt ("the page does not exist ");
// Write the modified personal information to the database
$ User = D ("user ");
$ Id = SESSION ('user') ['id'];
$ Where ['id'] = $ ID;
// Use arrays to modify the database
$ Data ['email '] = I ('Post. address ');
$ Data ['telphone'] = I ('Post. telphone ');
$ Data ['last _ login_ip '] = I ('Post. last_login_ip ');
$ User-> where ($ where)-> Save ($ data );