PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
← All changes | backend/src/Controllers/Form/GetFormController.php +9 -13 1.0 → 1.5.1 View file →
@@ -36,10 +36,10 @@
36 36 FormService $formService,
37 37 FieldService $fieldService,
38 38 ConfirmationService $confirmationService
39 39 ) {
40 - $this->formService = $formService;
41 - $this->fieldService = $fieldService;
40 + $this->formService = $formService;
41 + $this->fieldService = $fieldService;
42 42 $this->confirmationService = $confirmationService;
43 43 }
44 44
45 45 /**
@@ -59,27 +59,23 @@
59 59 throw new InvalidArgumentException(
60 60 BackendStrings::getExceptionStrings()['invalid_request_data']
61 61 );
62 62 }
63 +
63 64 // Sanitize the input data
64 65 $formId = Sanitizer::sanitizeId($data->get_param('id'));
65 66
66 - $form = $this->formService->getFormById($formId);
67 -
68 - // Use the service to get fields with options
67 + $form = $this->formService->getFormById($formId);
69 68 $fieldsMap = $this->fieldService->getAllFieldsWithOptions($form->getId());
70 69 $form->setFields($fieldsMap);
71 70
72 - $confirmationsArr = $this->confirmationService->getConfirmationsById($formId);
71 + $defaultConfirmationId = $this->confirmationService->ensureDefaultConfirmationExists($formId);
73 72
74 - $confirmations = [];
75 -
76 - foreach ($confirmationsArr as $confirmation) {
77 - $confirmations[] = $confirmation->toArray();
78 - }
79 -
80 73 return new WP_REST_Response([
81 74 'message' => BackendStrings::getCommonStrings()['ok'],
82 - 'data' => array_merge($form->toArray(), ['confirmationId' => $confirmations[0]['id']])
75 + 'data' => array_merge($form->toArray(), [
76 + 'confirmationId' => $defaultConfirmationId,
77 + 'submissionNonce' => wp_create_nonce('ivyformsFrontSubmissionNonce_' . $formId),
78 + ]),
83 79 ], 200);
84 80 }
85 81 }