I would like to add/edit users in a table calles "users". One field that has to be filled is the fild passord, which only exists ONCE in the db-table. Is there a way to have an additional field ("re-enter password") in the add7edit dialogue and to submit data only when both fields contain the same value?
Kind regards…
Michael
Yes, you can have another virtual column (non db) that will be only shown in edit form.
$col = array();
$col["title"] = "Re-enter Password";
$col["name"] = "reenter_pass";
$col["width"] = "50";
$col["editable"] = true;
// only show on edit
$col["show"]["edit"] = true;
$col["show"]["list"] = false;
$col["show"]["add"] = false;
Next, in on_update event handler you can compare it's value with actual pass data and unset it so that it does not become part of update query:
// set 3rd param to true to run default update query after function
$e["on_update"] = array("update_client", null, true);
function update_client($data)
{
if ($data["params"]["pass"] != $data["params"]["reenter_pass"])
phpgrid_error("Passwords must match");
unset($data["params"]["reenter_pass"]);
}