diff --git a/Tina4/Routing/Crud.php b/Tina4/Routing/Crud.php index 048a50b4..26f804c3 100644 --- a/Tina4/Routing/Crud.php +++ b/Tina4/Routing/Crud.php @@ -255,8 +255,17 @@ function (Response $response, Request $request) use ($object, $function) { function (Response $response, Request $request) use ($object, $function) { $id = $request->inlineParams[count($request->inlineParams) - 1]; //get the id on the last param - if (!(new $object())->load("{$object->getFieldName($object->primaryKey)} = ?", [$id])) { - $jsonResult = $function("fetch", $object, null, $request); + /** + * Fix for when we want to edit a form + * Philip Malan + * 5 September 2024 + */ + + //Check if it is a form and not an api call + if (!empty($request->data->formToken)) { + if ((new $object())->load("{$object->getFieldName($object->primaryKey)} = ?", [$id])) { + $jsonResult = $function("fetch", $object, null, $request); + } } if (empty($jsonResult)) {