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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Add your MailerLite API key in the Control Panel under the addon's settings (**T
Every form's **Configure** page in the Control Panel gets a **MailerLite** section:

- **Enable MailerLite sync** — toggle syncing for the form on or off.
- **Group** — pick the MailerLite group subscribers are added to, loaded live from your account.
- **Groups** — pick the MailerLite groups subscribers are added to, loaded live from your account.
- **Field mapping** — map form fields to MailerLite subscriber fields. Map one field to `email`; submissions without an email value are skipped.

The settings are saved on the form itself, so they are version controlled and deployed along with your other form YAML.
Expand Down
5 changes: 2 additions & 3 deletions src/StatamicMailerLiteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ public static function configFields(): array
],
'mailerlite_group' => [
'type' => 'mailer_lite_groups',
'display' => __('Group'),
'instructions' => __('Subscribers will be added to this MailerLite group.'),
'display' => __('Groups'),
'instructions' => __('Subscribers will be added to these MailerLite groups.'),
'mode' => 'select',
'max_items' => 1,
'show_when' => [
'mailerlite_enabled' => true,
],
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/MailerLiteConfigFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
expect($fields['mailerlite_enabled']['type'])->toBe('toggle');
expect($fields['mailerlite_enabled']['default'])->toBeFalse();
expect($fields['mailerlite_group']['type'])->toBe('mailer_lite_groups');
expect($fields['mailerlite_group']['max_items'])->toBe(1);
expect($fields['mailerlite_group'])->not->toHaveKey('max_items');
expect($fields['mailerlite_field_mapping']['type'])->toBe('grid');
});

Expand Down
17 changes: 17 additions & 0 deletions tests/Feature/SubmissionCreatedListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ function jobProperty(CreateSubscriberJob $job, string $name): mixed
);
});

it('passes multiple selected groups to the job', function () {
fakeApiKey('key-123');

$event = submissionEvent([
'mailerlite_enabled' => true,
'mailerlite_group' => ['42', '99'],
'mailerlite_field_mapping' => [['form_field' => 'email', 'mailerlite_field' => 'email']],
], ['email' => 'a@b.com']);

(new SubmissionCreatedListener)->handle($event);

Queue::assertPushed(
CreateSubscriberJob::class,
fn (CreateSubscriberJob $job) => jobProperty($job, 'subscriberGroups') === ['42', '99'],
);
});

it('dispatches without a group when none is selected', function () {
fakeApiKey('key-123');

Expand Down