Hi. I made a new button in an edit page to process the form, save the changes and process other things.
Is working kind of OK but never enter the "Client After" event. Any idea is appreciate.
This is the Code:
CLIENT BEFORE:
params["txt"] = "";
pageObj.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
formObj.baseParams['golist'] = "1";
});
$("#saveButton1").click();
return false;
Server
global $conn;
define(NL, "\n");
$result["error"] = "";
$data = $button->getCurrentRecord();
if ($data["ya_pdf"] != 1) $result["error"] .= "Error, falta PDF" . NL;
...
if ($data["ya_domicilio"] != 1) $result["error"] .= "Error, falta comprobante de domicilio" . NL;
echo ($result["error"] . NL);
if ($result["error"] == "") {
echo "no hay error " . $result["error"] . NL;
$sql = "INSERT INTO studentyear values('" . $data["alumnosID"] . "', '" . date("Y") . "')";
$rs = db_query($sql, $conn);
$result["txt"] = "Alumno registrado en el programa del año: " . date("Y");
}
echo "terminando " . $result["error"] . NL;
I can catch all the "echo"'s that apply in firebug
Client after
var errormsg = result["error"];
var message = result["txt"];
alert("después");
alert(errormsg);
alert(message);
if (result["error"] != "") {
alert(result["error"])
} else {
ctrl.setMessage(message);
}
Thanks in advance,