Skip to content

Commit

Permalink
Merge pull request #88 from philipmalan76/2.078-crud-bugfix
Browse files Browse the repository at this point in the history
Added fix in CRUD.php to check for the Edit form and then return the …
  • Loading branch information
andrevanzuydam authored Sep 5, 2024
2 parents 436d855 + f07cd8a commit 18753dd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Tina4/Routing/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* 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)) {
Expand Down

0 comments on commit 18753dd

Please sign in to comment.