Hi,
i need to save a generated string in a hidden column when i submit the form to the database. How can i achieve this?
Many thanks in advance :-)
This question has an accepted answers - jump to answer
check https://editor.datatables.net/reference/event/preSubmit or https://editor.datatables.net/reference/api/submit()
Hi nguyenm9,
thank you for your answer :-)
since i'm new in DataTables, i code it like this:
editor.on( 'onInitCreate', function () { editor .set( 'id', 'wrh_test_test1827' ) .hide('id'); } );
but no new records are saved in the database :-(
should i do it in a different way?
Thanks in advance
The preSubmit method that @nguyenm9 linked to is probably the best way. You would use something like:
preSubmit
editor.on( 'preSubmit', function ( e, d ) { d.data.myExtraField = "myValue"; } );
Then myExtraField is submitted to the server.
myExtraField
Perhaps another option is to use the hidden field type and set its value in the initCreate event if you wanted.
hidden
initCreate
Allan
Thank you both have a good one :-)
It looks like you're new here. If you want to get involved, click one of these buttons!
Answers
check https://editor.datatables.net/reference/event/preSubmit or https://editor.datatables.net/reference/api/submit()
Hi nguyenm9,
thank you for your answer :-)
since i'm new in DataTables, i code it like this:
editor.on( 'onInitCreate', function () {
editor
.set( 'id', 'wrh_test_test1827' )
.hide('id');
} );
but no new records are saved in the database :-(
should i do it in a different way?
Thanks in advance
The
preSubmit
method that @nguyenm9 linked to is probably the best way. You would use something like:Then
myExtraField
is submitted to the server.Perhaps another option is to use the
hidden
field type and set its value in theinitCreate
event if you wanted.Allan
Thank you both
have a good one :-)