How do I send/perform additional data on server-side (PHP) with Editor?
How do I send/perform additional data on server-side (PHP) with Editor?
Hi,
I recently posted a question related to this topic on the Free Forum at (https://datatables.net/forums/discussion/22288/how-do-i-save-encoded-password-entries-when-using-datatables-editor#latest), but to little response. Now I am rephrasing the question so that I can drill to specific problems and then hope to get specific responses to these questions I raised.
The first thing I noticed about using Editor for DataTables is that only fields present in the Editor frame could send the data to the database. So my 1st question is, how do I create a hidden field within that Editor frame to store a hidden variable so that when the user clicks Create or Update in that Editor frame, all visible and hidden field data can be sent to the database?
Another thing that I wish to do is that just before all data from Editor is written into the database's table, I would like to intercept at least 1 field from Editor (eg. password) and modify the data (i.e. hash it) and then write that modified data into the DB. The problem now is that with Editor/Datatables, even though I specify "type":"password" for the Password field, the data appearing in the DB is not encrypted. How do I intercept a field from Editor just before saving it to the DB?
The last thing is that I would like to write additional data into the DB from a PHP script, so how do I signal the Editor.php/Editor.js files to get that additional data from an external PHP script, then send both Editor fields and extra data (processed by external PHP script) to the DB?
[Code can be found in the URL: https://datatables.net/forums/discussion/22288/how-do-i-save-encoded-password-entries-when-using-datatables-editor]
Replies
Use the
hidden
field type :-). Documentation for it is available here: http://editor.datatables.net/reference/field/hidden .Do you want to do that in PHP on the server-side? If so, use:
changing the hashing function and
password
parameter as you need of course.You can get extra data in the data request using the same method that is in the Join examples for populating the select lists: http://editor.datatables.net/examples/simple/join.html (click on the
Server script
tab and look at line 30).To send extra data, you can either use hidden fields,
preSubmit
,ajax.data
as you require.Allan
Update for anyone that finds this post, you may wish to use a set formatter to password encode:
Allan
OK but the better way is to do that on Client side!
How can i replace the original password on client with the decoded password and send only the decoded to the server?
what I need: how can I do that on client:
?
You'd need a crytpo library in Javascript that can create SHA1 hashes - for example you might use crypto-js.
Allan
OK crypto was not the problem I have found the solution:
I update the field in the
works fine for me
Are you using something like this for
hex_sha512
?One thing, you might want to use:
since multiple could be updated at a single time (unless you are using an old version of Editor).
Allan