new entry in table comes with 0 in fields without value
new entry in table comes with 0 in fields without value
Hi,
I have this editor:
editor_freigaben = new $.fn.dataTable.Editor( {
ajax: "../../../../../../DataTables/Editor/controllersKontura/freigabe_PID_St_INP_ofb.php",
table: "#liste_freigaben",
fields: [
{ label: "wurst", name: "V_Freigaben.freig_erledigt_wann" , type: "hidden"},
{ label: "wurst", name: "V_Freigaben.freig_erledigt_durch" , type: "hidden"},
{ label: "freig_erledigt", name: "V_Freigaben.freig_erledigt", type: "hidden" },
{ label: "Freigeber", name: "V_Freigaben.freig_person", placeholder: "Bitte wählen", type: "radio" },
{ label: "INP ID", name: "V_Freigaben.INP_ID", default: "__INP_ID__", type: "hidden"},
{ label: "freig_angefordert_von", name: "V_Freigaben.freig_angefordert_von", default: "__thisPID__", type: "hidden" },
{ label: "Stapelname", name: "V_Freigaben.Stapelname", default: "__Stapelname__", type: "hidden" },
{ label: "Begründung", name: "V_Freigaben.freig_angefordert_wie", default: "Portal", type: "hidden", default: "Portal"}
],
formOptions: { inline: { onBlur: 'submit'}},
} );
Problem is that when I add a new row, I have a 0 in the fields freig_erledigt_durch and freig_erledigt_wann. I want them to have a NULL.
I can not delete them from the editor, because I need them for some other function.
This is what is send to the server:
{
"2": {
"query": "INSERT INTO [V_Freigaben] ( [INP_ID], [Stapelname], [freig_person], [freig_angefordert_wie], [freig_erledigt], [freig_erledigt_durch], [freig_erledigt_wann], [freig_angefordert_von] ) VALUES ( :INP_ID, :Stapelname, :freig_person, :freig_angefordert_wie, :freig_erledigt, :freig_erledigt_durch, :freig_erledigt_wann, :freig_angefordert_von )",
"bindings": [
{
"name": ":INP_ID",
"value": "13",
"type": null
},
{
"name": ":Stapelname",
"value": "220030_2106171638",
"type": null
},
{
"name": ":freig_person",
"value": "3",
"type": null
},
{
"name": ":freig_angefordert_wie",
"value": "Portal",
"type": null
},
{
"name": ":freig_erledigt",
"value": "",
"type": null
},
{
"name": ":freig_erledigt_durch",
"value": "",
"type": null
},
{
"name": ":freig_erledigt_wann",
"value": "",
"type": null
},
{
"name": ":freig_angefordert_von",
"value": "3",
"type": null
}
]
}
}
this what comes back:
{
"V_Freigaben": {
"ID_freigabe": "2589",
"INP_ID": "13",
"Stapelname": "220030_2106171638",
"freig_person": "3",
"freig_person2": "3",
"freig_angefordert_wann": "2021-06-18 12:53:47.100",
"freig_angefordert_wie": "Portal",
"freig_erledigt": "0",
"freig_erledigt_durch": "0",
"freig_erledigt_wann": "1900-01-01 00:00:00.000",
"freig_abl_grund": null,
"freig_angefordert_von": "3",
"freig_zahlsperre": null,
"zahlsperreInfo": "nein"
}
}
Thanks
Max
This question has an accepted answers - jump to answer
Answers
Just to confirm - when you submit empty data for those fields, you want
null
to appear in the database? If so, use theifEmpty()
formatter.Regards,
Allan
thanks!