diff --git a/src/FormConnectors/HubSpot/HubSpotClient.php b/src/FormConnectors/HubSpot/HubSpotClient.php index feddd8a..50aa7f0 100644 --- a/src/FormConnectors/HubSpot/HubSpotClient.php +++ b/src/FormConnectors/HubSpot/HubSpotClient.php @@ -84,7 +84,7 @@ private function summarise(array $form): array return [ 'name' => $form['name'], 'properties' => $fields - ->reject(fn (array $field): bool => $field['name'] === 'email') + ->reject(fn (array $field): bool => $field['name'] === 'email' || ($field['hidden'] ?? false)) ->map(fn (array $field): array => Arr::removeNullValues([ 'name' => $field['name'], 'label' => $field['label'], diff --git a/tests/FormConnectors/HubSpot/HubSpotConnectorTest.php b/tests/FormConnectors/HubSpot/HubSpotConnectorTest.php index fa4367e..99e6fcd 100644 --- a/tests/FormConnectors/HubSpot/HubSpotConnectorTest.php +++ b/tests/FormConnectors/HubSpot/HubSpotConnectorTest.php @@ -211,6 +211,27 @@ public function it_excludes_the_email_property_from_the_summary() $this->assertNotContains('email', array_column($properties, 'name')); } + /** + * @see https://github.com/statamic/forms-pro/issues/38 + */ + #[Test] + public function it_excludes_hidden_properties_from_the_summary() + { + $definition = $this->definition(); + $definition['fieldGroups'][0]['fields'][] = [ + 'objectTypeId' => '0-1', 'name' => 'lead_source', 'required' => false, 'hidden' => true, + ]; + + $this->fakeHttp([ + 'api.hubapi.com/marketing/v3/forms*' => Http::response(['results' => [$definition]]), + 'api.hubapi.com/communication-preferences/*' => Http::response(['subscriptionDefinitions' => []]), + ]); + + $properties = (new HubSpot)->forForm($this->form())->render()->toArray()['props']['hubspotForms'][self::FORM]['properties']; + + $this->assertNotContains('lead_source', array_column($properties, 'name')); + } + #[Test] public function it_still_renders_the_forms_when_the_subscription_lookup_fails() {