Fieldtype cleanup: memoized groups, FormFields rename - #11
Merged
Conversation
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
MailerLiteGroups— brought in line withMailerLiteFields:MailerLiteFields). Previously every selected value resolved throughtoItemArray()triggered its owngroups->find($id)API call.rescue()and degrade to an empty list instead of bubbling a 500 into the Control Panel.MailerLiteFields— dropped thecanCreate,canEdit,canSearchandstatusIconsoverrides. TheRelationshipbase class already defaults all four tofalse, so they were dead weight.MailerLiteFormFields→FormFields— the fieldtype lists the Statamic form's own fields, not MailerLite data, so the prefix was misleading. Handle changes frommailer_lite_form_fieldstoform_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 aform_fieldsfieldtype — acceptable trade-off flagged for the record.Includes a
MailerLiteGroupstest (no API key → empty list), mirroring the existingMailerLiteFieldstest.