Как изменить заголовок модального окна? - PullRequest
0 голосов
/ 07 ноября 2018

У меня есть ссылка, которая отображает модальное окно.

Когда я нажимаю на нее, она отмечается в заголовке модального окна «Массив».

Как настроить заголовок?

Вот мой модуль Drupal:

/ src / Plugin / Commerce / CheckoutPane / MarketplaceTermsAndConditions.php:

<?php

namespace Drupal\commerce_marketplace_terms_and_conditions\Plugin\Commerce\CheckoutPane;

use Drupal\Component\Serialization\Json;
use Drupal\Core\Form\FormStateInterface;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneBase;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;

/**
 * Provides the completion message pane.
 *
 * @CommerceCheckoutPane(
 *   id = "marketplace_terms_and_conditions",
 *   label = @Translation("Marketplace Terms and Conditions"),
 *   default_step = "review",
 * )
 */
class MarketplaceTermsAndConditions extends CheckoutPaneBase implements CheckoutPaneInterface {

  /**
   * {@inheritdoc}
   */
  public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
    $store_name = $this->order->getStore()->getName();
    $store_id = $this->order->getStoreId();
    $pane_form['#attached']['library'][] = 'core/drupal.dialog.ajax';
    $attributes = [
      'attributes' => [
        'class' => 'use-ajax',
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode([
          'width' => auto,
        ]),
      ],
    ];
    $link = Link::fromTextAndUrl(
      $this->t('terms and conditions of the store "@store_name"', ['@store_name' => $store_name]),
      Url::fromUri("internal:/store/$store_id/cgv", $attributes)
    )->toString();
    $pane_form['marketplace_terms_and_conditions'] = [
      '#type' => 'checkbox',
      '#default_value' => FALSE,
      '#title' => $this->t('I have read and accept @terms.', ['@terms' => $link]),
      '#required' => TRUE,
      '#weight' => $this->getWeight(),
    ];
    return $pane_form;
  }

}

commerce_marketplace_terms_and_conditions.info.yml:

name: Commerce Marketplace Terms and Conditions
description: Commerce checkout pane with a checkbox linked to your custom Marketplace Terms and Conditions page.
type: module
core: 8.x
package: Commerce (contrib)
dependencies:
  - commerce:commerce_checkout

commerce_marketplace_terms_and_conditions.module:

<?php

/**
 * @file
 * Commerce marketplace terms and conditions.
 */

Вот скриншот текущего модального окна:

enter image description here

1 Ответ

0 голосов
/ 07 ноября 2018

Просто напишите название, которое вы хотите иметь для этого окна, внутри функции t ().

...