Skip to content

Beautiful Open-Source Form Builder

Enhance FormController to include cleaning data in form responses

Chirag Chhatrala80bbe148737e
diff --git a/api/app/Http/Controllers/Forms/FormController.php b/api/app/Http/Controllers/Forms/FormController.php
index 2fc83f192..e6a501bd0 100644
--- a/api/app/Http/Controllers/Forms/FormController.php
+++ b/api/app/Http/Controllers/Forms/FormController.php
@@ -42,14 +42,23 @@ class FormController extends Controller
->orderByDesc('updated_at')
->paginate(10);
- return FormResource::collection($forms);
+ $formCollection = FormResource::collection($forms);
+ $formCollection->each(function ($formResource) {
+ $formResource->setCleanings(
+ $this->formCleaner->processForm(request(), $formResource->resource)->simulateCleaning($formResource->resource->workspace)->getPerformedCleanings()
+ );
+ });
+
+ return $formCollection;
}
public function show(Form $form)
{
$this->authorize('view', $form);
- return new FormResource($form);
+ return (new FormResource($form))->setCleanings(
+ $this->formCleaner->processForm(request(), $form)->simulateCleaning($form->workspace)->getPerformedCleanings()
+ );
}
/**