public function MailchimpListsSelectWidget::getSubscribeFromInterests in Mailchimp 2.x
Sets the subscribe value based on field settings and interest groups.
Parameters
$choices: The value of the field.
Return value
bool TRUE if there are interests chosen on a hidden subscribe list checkbox.
1 call to MailchimpListsSelectWidget::getSubscribeFromInterests()
- MailchimpListsSelectWidget::massageFormValues in modules/
mailchimp_lists/ src/ Plugin/ Field/ FieldWidget/ MailchimpListsSelectWidget.php - Massages the form values into the format expected for field values.
File
- modules/
mailchimp_lists/ src/ Plugin/ Field/ FieldWidget/ MailchimpListsSelectWidget.php, line 345
Class
- MailchimpListsSelectWidget
- Plugin implementation of the 'mailchimp_lists_select' widget.
Namespace
Drupal\mailchimp_lists\Plugin\Field\FieldWidgetCode
public function getSubscribeFromInterests($choices) {
$subscribe_from_interest_groups = $choices['subscribe'];
$field_settings = $this
->getFieldSettings();
// Automatically subscribe if the field is configured to hide the
// subscribe checkbox and at least one interest group checkbox is checked.
if ($field_settings['show_interest_groups'] && $field_settings['hide_subscribe_checkbox']) {
if (!empty($choices['interest_groups'])) {
$subscribe_from_interest_groups = FALSE;
foreach ($choices['interest_groups'] as $group_id => $interests) {
foreach ($interests as $interest_id => $value) {
if (!empty($value)) {
$subscribe_from_interest_groups = TRUE;
break;
}
}
}
}
}
return $subscribe_from_interest_groups;
}