diff --git a/src/Concerto/APIBundle/Service/DataRecordService.php b/src/Concerto/APIBundle/Service/DataRecordService.php index 6345c3a49..c5a1d9044 100644 --- a/src/Concerto/APIBundle/Service/DataRecordService.php +++ b/src/Concerto/APIBundle/Service/DataRecordService.php @@ -75,8 +75,9 @@ public function updateData($table_id, $id, $newSerializedData, $format = "json") $columns = $this->dbStructureDAO->getColumns($table->getName()); foreach ($newData as $k => $v) { - if (!array_key_exists($k, $columns)) + if (!array_filter($columns, function($col) use($k) { return $col->getName() == $k; })) { return array("response" => Response::HTTP_BAD_REQUEST, "result" => null); + } } $this->dbDataDAO->updateRow($table->getName(), $id, $newData); @@ -97,8 +98,9 @@ public function insertData($table_id, $newSerializedData, $format = "json") $columns = $this->dbStructureDAO->getColumns($table->getName()); foreach ($newData as $k => $v) { - if (!array_key_exists($k, $columns)) + if (!array_filter($columns, function($col) use($k) { return $col->getName() == $k; })) { return array("response" => Response::HTTP_BAD_REQUEST, "result" => null); + } } $lid = $this->dbDataDAO->insertRow($table->getName(), $newData); @@ -185,4 +187,4 @@ protected function formatDataFilter(DataTable $table, &$filter) return true; } -} +} \ No newline at end of file