Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FormConnectors/HubSpot/HubSpotClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
21 changes: 21 additions & 0 deletions tests/FormConnectors/HubSpot/HubSpotConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down