public function updateCMSFlexiTabs(TabSet $fields, TabSet $settings_tab, $flexi) { parent::updateCMSFlexiTabs($fields, $settings_tab, $flexi); $mailchimp_tab = new Tab('MailChimp', 'MailChimp'); $fields->insertBefore($mailchimp_tab, 'Settings'); $client = new FlexiFormMailChimpClient($flexi->FlexiFormSetting('MailChimpApiKey')->getValue()); foreach ($this->stat('handler_settings') as $component => $class) { $field_name = $this->getSettingFieldName($component); $field = $this->augmentMailChimpField($settings_tab->fieldByName($field_name), $component, $client); // Move Settings to designated MailChimp Tab $settings_tab->removeByName($field_name); $mailchimp_tab->push($field); } // integrate list groups if ($list_id = $flexi->FlexiFormSetting('MailChimpListID')->getValue()) { $field = new CheckboxSetField('FlexiFormMailChimpGroups', 'List Groups'); if ($list_groups = $this->getInterestGroups($list_id, $client)) { $field->setSource($list_groups->map('id', 'name')); $field->setValue($flexi->FlexiFormFields()->filter('ClassName', 'FlexiMailChimpInterestGroupField')->column('InterestGroupID')); $field->description = 'Checked groups are added to your form Fields. Groups are refreshed every 10 minutes.'; } else { $field = $field->performReadonlyTransformation(); $field->setValue('This list has no Interest Groups'); } $mailchimp_tab->push($field); } $mailchimp_tab->push(new LiteralField('MailChimpRefresh', '<br /><hr />NOTE: list and group selections are cached from mailchimp for up to 10 minutes. changing the API Key or list will cause a refresh.')); }