Date fields empty in Editor, date not showing up
Date fields empty in Editor, date not showing up
There seems to be an issue with shared fields and editor instances, that I cannot grasp: date fields don't show previously submitted values in editor and then empty the data on submission.
I am using this setup:
DateTime.use( moment );
let currentDate = new Date();
var editorfields = [{
label: "Datum",
name: "add_date",
type: 'datetime',
displayFormat: 'DD.MM.YYYY',
wireFormat: 'YYYY-MM-DD',
def: currentDate,
}...];
bookingeditor = new DataTable.Editor( {
table: "#bookingstable",
idSrc: 'id',
fields: editorfields,
ajax: {
create: {
type: 'POST',
url: datatablesajax.url,
data: {
action: 'createbooking',
},
dataType: "json",
},
edit: {
type: 'POST',
url: datatablesajax.url,
data: {
action: 'editbooking',
},
dataType: "json",
},
remove: {
type: 'POST',
url: datatablesajax.url,
data: {
action: 'deletebooking',
},
dataType: "json",
},
},
} );
and a second editor with a similar setup using the editorfields the same way
Now the first thing, that annoys me is that the date-picker shows the full names of weekdays and therefore breaks the layout, but it's usable nonetheless, so that's just annoying.
The main thing is: in another editor I use date fields already included in the editor setup, so not seperately declared as a variable, and here the datetime field is showing up and saving the correct data! So only when sharing the fields apparently there is an issue.
I've also experimented with different datefield setups like with display and wire formats, however none of them fixed the issue, so it's definitely not related to the format.
Answers
Very likely an issue with the date formatting. Which page is this visible on, and I'll take a look?
Allan
@allan I've updated the dev space I sent you with the current script, so you can test it on the page https://dev.resqonline.eu/devtest/wp-admin/admin.php?page=esibackoffice_bookings
As mentioned I've tested with and without formatting and the field always appears empty. Maybe it's a kind of decleration order? But the fields are included in the script before the actual editors, so that should be fine I guess.