public static function MailchimpCampaignForm::listSegmentCallback in Mailchimp 8
Same name and namespace in other branches
- 2.x modules/mailchimp_campaign/src/Form/MailchimpCampaignForm.php \Drupal\mailchimp_campaign\Form\MailchimpCampaignForm::listSegmentCallback()
 
Ajax callback to render audience segments when an audience is selected.
Parameters
array $form: Form API array structure.
\Drupal\Core\Form\FormStateInterface $form_state: Form state information.
Return value
\Drupal\Core\Ajax\AjaxResponse Ajax response with the rendered list/audience segments element.
File
- modules/
mailchimp_campaign/ src/ Form/ MailchimpCampaignForm.php, line 438  
Class
- MailchimpCampaignForm
 - Form controller for the MailchimpCampaign entity edit form.
 
Namespace
Drupal\mailchimp_campaign\FormCode
public static function listSegmentCallback(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $list_segment_html = \Drupal::service('renderer')
    ->render($form['list_segment_id']);
  $response
    ->addCommand(new ReplaceCommand('#list-segments-wrapper', $list_segment_html));
  if (isset($form['content']['html_wrapper']['merge_vars'])) {
    $merge_vars_html = \Drupal::service('renderer')
      ->render($form['content']['html_wrapper']['merge_vars']);
    $response
      ->addCommand(new ReplaceCommand('.merge-vars-wrapper', $merge_vars_html));
  }
  return $response;
}