You are here

public function MailchimpEcommerceUbercartAdminSettings::buildForm in Mailchimp E-Commerce 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides MailchimpEcommerceAdminSettings::buildForm

File

modules/mailchimp_ecommerce_ubercart/src/Form/MailchimpEcommerceUbercartAdminSettings.php, line 13

Class

MailchimpEcommerceUbercartAdminSettings

Namespace

Drupal\mailchimp_ecommerce_ubercart\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);

  // TODO Get default currency
  if (!empty($store)) {

    // Set default currency code for the Mailchimp store.
    $default_currency = $store
      ->getDefaultCurrencyCode();
    if (isset($form['mailchimp_ecommerce_currency']['#options'][$default_currency])) {
      $form['mailchimp_ecommerce_currency']['#default_value'] = $default_currency;
    }
  }

  // Identify Ubercart to Mailchimp.
  $form['platform']['#default_value'] = 'Drupal Ubercart';
  return $form;
}