From e27a1c4d729ebe225064a9a5c69578743fcf1834 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Fri, 8 Nov 2024 11:35:38 -0300 Subject: [PATCH] refactor: change how to set the isDefaultCampaignForm value --- src/DonationForms/V2/Endpoints/ListDonationForms.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/DonationForms/V2/Endpoints/ListDonationForms.php b/src/DonationForms/V2/Endpoints/ListDonationForms.php index b076e5b4bd..f90aff393d 100644 --- a/src/DonationForms/V2/Endpoints/ListDonationForms.php +++ b/src/DonationForms/V2/Endpoints/ListDonationForms.php @@ -136,13 +136,15 @@ public function handleRequest(WP_REST_Request $request): WP_REST_Response $this->listTable->items($forms, $this->request->get_param('locale') ?? ''); $items = $this->listTable->getItems(); + $defaultCampaignForm = Campaign::find($this->request->get_param('campaignId'))->defaultForm(); + foreach ($items as $i => &$item) { $item['name'] = get_the_title($item['id']); $item['edit'] = get_edit_post_link($item['id'], 'edit'); $item['permalink'] = get_permalink($item['id']); $item['v3form'] = (bool)give_get_meta($item['id'], 'formBuilderSettings'); $item['status_raw'] = $forms[$i]->status->getValue(); - $item['isDefaultCampaignForm'] = ($campaign = Campaign::findByFormId($item['id'])) && $item['id'] === $campaign->defaultForm()->id; + $item['isDefaultCampaignForm'] = $item['id'] === $defaultCampaignForm->id; } }