Skip to content

Fieldtype cleanup: memoized groups, FormFields rename - #11

Merged
jhhazelaar merged 3 commits into
0.xfrom
f/jh/relationship-fieldtype-cleanup
Jul 13, 2026
Merged

Fieldtype cleanup: memoized groups, FormFields rename#11
jhhazelaar merged 3 commits into
0.xfrom
f/jh/relationship-fieldtype-cleanup

Conversation

@jhhazelaar

@jhhazelaar jhhazelaar commented Jul 13, 2026

Copy link
Copy Markdown
Member

Changes

MailerLiteGroups — brought in line with MailerLiteFields:

  • The group list is now fetched once per request and memoized (same static cache pattern as MailerLiteFields). Previously every selected value resolved through toItemArray() triggered its own groups->find($id) API call.
  • API failures are now swallowed via rescue() and degrade to an empty list instead of bubbling a 500 into the Control Panel.

MailerLiteFields — dropped the canCreate, canEdit, canSearch and statusIcons overrides. The Relationship base class already defaults all four to false, so they were dead weight.

MailerLiteFormFieldsFormFields — the fieldtype lists the Statamic form's own fields, not MailerLite data, so the prefix was misleading. Handle changes from mailer_lite_form_fields to form_fields (same convention as statamic-rad-pack/mailchimp). The handle only exists in runtime blueprint registration, so no stored form config is affected. Note: if a site ever installs this addon alongside the rad-pack Mailchimp addon, both register a form_fields fieldtype — acceptable trade-off flagged for the record.

Includes a MailerLiteGroups test (no API key → empty list), mirroring the existing MailerLiteFields test.

MailerLiteGroups fetched a group from the API for every selected value
it resolved and let API errors bubble into the Control Panel. It now
reuses a request-memoized group list and swallows API failures, exactly
like MailerLiteFields already did. Also drops the canCreate, canEdit,
canSearch and statusIcons overrides from MailerLiteFields, which only
restated the Relationship base class defaults.

Changelog: performance
The fieldtype lists the Statamic form's own fields, not MailerLite
data, so the MailerLite prefix was misleading. The handle changes from
mailer_lite_form_fields to form_fields (matching the rad-pack Mailchimp
convention); it only exists in runtime blueprint registration, so no
stored form config is affected.

Changelog: changed
@jhhazelaar jhhazelaar changed the title Memoize MailerLite group lookups Fieldtype cleanup: memoized groups, FormFields rename Jul 13, 2026
The Group and Field mapping fields are meaningless while MailerLite
sync is off, so they now only appear once the toggle is enabled,
keeping the form configure page uncluttered.

Changelog: changed
@jhhazelaar
jhhazelaar merged commit 52e48f3 into 0.x Jul 13, 2026
35 checks passed
@jhhazelaar
jhhazelaar deleted the f/jh/relationship-fieldtype-cleanup branch July 13, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant