You are here

public function CartLinksSettingsForm::buildForm in Ubercart 8.4

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 ConfigFormBase::buildForm

File

uc_cart_links/src/Form/CartLinksSettingsForm.php, line 61

Class

CartLinksSettingsForm
Configure general shopping cart settings for this site.

Namespace

Drupal\uc_cart_links\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $cart_links_config = $this
    ->config('uc_cart_links.settings');
  $form['uc_cart_links_add_show'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display the Cart Link product action when you add a product to your cart.'),
    '#default_value' => $cart_links_config
      ->get('add_show'),
  ];
  $form['uc_cart_links_track'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Track clicks through Cart Links that specify tracking IDs.'),
    '#default_value' => $cart_links_config
      ->get('track'),
  ];
  $form['uc_cart_links_empty'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Allow Cart Links to empty customer carts.'),
    '#default_value' => $cart_links_config
      ->get('empty'),
  ];
  $form['uc_cart_links_messages'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Cart Links messages'),
    '#description' => $this
      ->t('Enter messages available to the Cart Links API for display through a link. Separate messages with a line break. Each message should have a numeric key and text value, separated by "|". For example: 1337|Message text.'),
    '#default_value' => $cart_links_config
      ->get('messages'),
  ];
  $form['uc_cart_links_restrictions'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Cart Links restrictions'),
    '#description' => $this
      ->t('To restrict what Cart Links may be used on your site, enter all valid Cart Links in this textbox.  Separate links with a line break. Leave blank to permit any Cart Link.'),
    '#default_value' => $cart_links_config
      ->get('restrictions'),
  ];
  $form['uc_cart_links_invalid_page'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Invalid link redirect page'),
    '#description' => $this
      ->t('Enter the URL to redirect to when an invalid Cart Link is used.'),
    '#default_value' => $cart_links_config
      ->get('invalid_page'),
    '#size' => 32,
    '#field_prefix' => Url::fromRoute('<front>', [], [
      'absolute' => TRUE,
    ])
      ->toString(),
  ];
  return parent::buildForm($form, $form_state);
}