Example:
I want to post id (INT value) and bookName (INT value) to a custom PHP file with “Includes common files” enabled.
The function create a form, append it to the document and send it immediately.
First I create the new “MyNewColumn” in ListOptions_Load and then in ListOptions_Rendered I call the function this way:
$parametri = json_encode(array(
"id" => "MyUniqueFormId", // You can use uniqid() if you want
"method" => "post",
"action" => "custom_file_path",
"id" => $this->id->DbValue,
"bookName" => $this->bookName->DbValue
));
$this->ListOptions["MyNewColumn"]->Body = "<a href='#' class='btn btn-sm ew-tooltip btn-primary' title='ToolTip Text' onclick='faiLaForm(`$parametri`);'>POST BUTTON TEXT</a>";
The Js function:
function faiLaForm(pp) {
var parametri = JSON.parse(pp);
parametri[ew.TOKEN_NAME_KEY] = ew.TOKEN_NAME;
parametri[ew.ANTIFORGERY_TOKEN_KEY] = ew.ANTIFORGERY_TOKEN;
var form = document.createElement("form");
form.id = parametri.id;
form.method = parametri.method;
form.action = parametri.action;
for (const [key, value] of Object.entries(parametri)) {
if (["id", "action", "method"].includes(key)) {
continue;
};
var elmtArray = document.createElement("input");
elmtArray.type = "hidden";
elmtArray.name = key;
elmtArray.value = value;
form.appendChild(elmtArray);
}
document.body.appendChild(form);
document.getElementById(parametri.id).submit();
}