You are here

protected function MailchimpListsSelectWidget::setupUnsubscribeCheckbox in Mailchimp 2.x

Parameters

array $element:

FormStateInterface $form_state:

$instance:

$email:

$hide_subscribe_checkbox:

$mailchimp_list_id:

Return value

array

1 call to MailchimpListsSelectWidget::setupUnsubscribeCheckbox()
MailchimpListsSelectWidget::formElement in modules/mailchimp_lists/src/Plugin/Field/FieldWidget/MailchimpListsSelectWidget.php
Returns the form for a single field widget.

File

modules/mailchimp_lists/src/Plugin/Field/FieldWidget/MailchimpListsSelectWidget.php, line 196

Class

MailchimpListsSelectWidget
Plugin implementation of the 'mailchimp_lists_select' widget.

Namespace

Drupal\mailchimp_lists\Plugin\Field\FieldWidget

Code

protected function setupUnsubscribeCheckbox(array $element, $form_state, $instance, $email, $hide_subscribe_checkbox, $at_least_one_interest_group, $mailchimp_list_id) {
  if ($this
    ->subscribeCheckboxShown($form_state, $hide_subscribe_checkbox, $at_least_one_interest_group, $email, $mailchimp_list_id)) {

    // When the subscribe checkbox is shown, we don't need to show
    // the unsubscribe checkbox (unchecked subscribe means the
    // same thing as unsubscribed).
    return $element;
  }
  $memberStatus = $this
    ->GetMemberStatus($instance, $email);
  if ($memberStatus == 'subscribed') {
    $element['unsubscribe'] = [
      '#title' => t("Unsubscribe"),
      '#type' => 'checkbox',
      '#weight' => 101,
      '#default_value' => FALSE,
    ];
  }
  return $element;
}