From 85712a1960003a4b37ce653d3d90480daa0dee1d Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 30 Apr 2020 20:59:42 -0700 Subject: [PATCH] =?UTF-8?q?Only=20override=20fieldset=5Fid=20with=20custom?= =?UTF-8?q?=5Ffieldset=5Fid=20if=20it=E2=80=99s=20present?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is mostly to support prior versions. I have NFC why we did this in the first place. I’m sure I had a stellar reason, but couldn’t tell you what it is today. Signed-off-by: snipe --- app/Http/Controllers/Api/AssetModelsController.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/AssetModelsController.php b/app/Http/Controllers/Api/AssetModelsController.php index 5ad7c8bcbc..be8d28593a 100644 --- a/app/Http/Controllers/Api/AssetModelsController.php +++ b/app/Http/Controllers/Api/AssetModelsController.php @@ -154,7 +154,19 @@ class AssetModelsController extends Controller $this->authorize('update', AssetModel::class); $assetmodel = AssetModel::findOrFail($id); $assetmodel->fill($request->all()); - $assetmodel->fieldset_id = $request->get("custom_fieldset_id"); + + /** + * Allow custom_fieldset_id to override and populate fieldset_id. + * This is stupid, but required for legacy API support. + * + * I have no idea why we manually overrode that field name + * in previous versions. I assume there was a good reason for + * it, but I'll be damned if I can think of one. - snipe + */ + if ($request->filled('custom_fieldset_id')) { + $assetmodel->fieldset_id = $request->get("custom_fieldset_id"); + } + if ($assetmodel->save()) { return response()->json(Helper::formatStandardApiResponse('success', $assetmodel, trans('admin/models/message.update.success')));