Hidden form inputs are not POSTed to server as expected
Hidden form inputs are not POSTed to server as expected

Hello,
I have a datatable with select, input and checkboxes. Columns can be hidden/shown by the user. My problem is that form data is not being posted to the server from columns marked as visible:false.
I have decided to try and add the hidden fields to the bottom of my form, which appears to work. However any changes to the inputs are not persisted, and only post the data that was originally in the form at page load.
Please can someone help?
Thanks
var table = jQuery('table.list').dataTable({
"paging": false,
"searching": false,
"autoWidth": false,
"order": [[ 2, "asc" ]],
"columnDefs": [
{ "orderable": false, "targets": [-1, 0, 3, 4, 5, 6, 7] },
{"targets": [ 3 ], "visible": jQuery('.column-selector :checkbox[data-column="3"]').is(":checked")},
{"targets": [ 4 ], "visible": jQuery('.column-selector :checkbox[data-column="4"]').is(":checked")},
{"targets": [ 5 ], "visible": jQuery('.column-selector :checkbox[data-column="5"]').is(":checked")}
// etc
]
});
jQuery('form').submit(function(e){
e.stopPropagation();
// all currently shown inputs
var displayedData = jQuery('input, select, checkbox', jQuery(table.selector));
// all inputs including hidden ones
var hiddenTableData = jQuery('input, select, checkbox', jQuery(table.api().cells().data().toArray().toString()));
var div = jQuery('<div>');
hiddenTableData.each(function () {
var selector = jQuery(this).attr('name').replace(/(:|\.|\[|\])/g, '\\$1');
var filter = displayedData.filter('[name=' + selector + ']').length;
if (filter === 0) {
jQuery("<input>").attr({
type: "hidden",
name: $(this).attr('name'),
value: $(this).val(),
}).appendTo(div);
}
});
div.appendTo(this);
return false;
});
I have spent over a day on this so far and various searching seems to bring up legacy solutions and now I am very confused.
Thanks
Jon
Answers
I'm guessing this isn't using Editor?
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin