Support required fields - report information into backend
authorJoey Schulze <joey@infodrom.org>
Sun, 28 Feb 2010 16:56:14 +0000 (17:56 +0100)
committerJoey Schulze <joey@infodrom.org>
Sun, 28 Feb 2010 16:56:14 +0000 (17:56 +0100)
ajax/ajax.php

index bbef0e4..e973776 100644 (file)
@@ -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;