64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: scaffolding_save.asp
|
|
Description: save information from scaffolding_edit.asp
|
|
|
|
Parameters:
|
|
|
|
Context:
|
|
Note:
|
|
|
|
*/
|
|
|
|
function scaffolding_save(model, scf_params)
|
|
{
|
|
protectRequest.validateToken();
|
|
var key = getQParamInt( "id" );
|
|
|
|
var formfields = [];
|
|
for (var fld in model.fields)
|
|
{
|
|
var field = model.fields[fld];
|
|
if (fld == "id")
|
|
continue;
|
|
if (fld.readonly)
|
|
continue;
|
|
if (field.insertonly && key > 0)
|
|
continue;
|
|
formfields.push({ name: fld, frm: fld });
|
|
}
|
|
|
|
var params = { filter: { "id": key } };
|
|
var jsondata = api2.form2JSONdata(model, params, formfields);
|
|
params.properties = { extraserie: false,
|
|
nameprefix: "k"
|
|
};
|
|
if (model.includes && "custom_fields" in model.includes)
|
|
jsondata.custom_fields = flexkenmerken2jsondata(params.properties);
|
|
|
|
if (key > 0)
|
|
{
|
|
if ("hook_pre_put" in model)
|
|
model.hook_pre_put(params, jsondata, key);
|
|
var restresult = model.REST_PUT(params, jsondata, key);
|
|
}
|
|
else
|
|
{
|
|
if ("hook_pre_post" in model)
|
|
model.hook_pre_post(params, jsondata);
|
|
var restresult = model.REST_POST(params, jsondata);
|
|
key = restresult.key;
|
|
}
|
|
var warning = restresult.warning;
|
|
|
|
var result = { key: key,
|
|
warning: warning,
|
|
keepForm: !!warning,
|
|
success: true };
|
|
Response.ContentType = "application/json";
|
|
Response.Write(JSON.stringify(result));
|
|
}
|
|
%>
|