From ecdf9b356e69b18539688ccf09529e2f3a47f149 Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Sun, 28 Feb 2010 17:56:14 +0100 Subject: [PATCH] Support required fields - report information into backend --- ajax/ajax.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ajax/ajax.php b/ajax/ajax.php index bbef0e4..e973776 100644 --- a/ajax/ajax.php +++ b/ajax/ajax.php @@ -68,6 +68,10 @@ function save($mask) "sys_edit = now()"); foreach ($mask['edit'] as $field => $info) + if ($info['required'] === true && empty($_POST[$field])) + return array('error' => sprintf('Pflichtfeld %s nicht ausgefüllt', $info['name']), + 'errormsg' => 'Pflichtfelder nicht ausgefüllt'); + if ($info['type'] == 'boolean') { $update[] = sprintf("%s=%d", $field, $_POST[$field] == 'on'?1:0); } elseif ($info['type'] == 'number') { @@ -111,6 +115,9 @@ function insert($mask) $values = array("'".pg_escape_string($_SESSION['sys']['login'])."'", 'now()'); foreach ($mask['edit'] as $field => $info) + if ($info['required'] === true && empty($_POST[$field])) + return array('error' => sprintf('Pflichtfeld %s nicht ausgefüllt', $info['name']), + 'errormsg' => 'Pflichtfelder nicht ausgefüllt'); if ($info['type'] == 'boolean') { $fields[] = $field; $values[] = $_POST[$field] == 'on'?1:0; -- 2.20.1