I have a link that displays a modal window.

When I click on it, it is marked in the title of the modal window "Array".

How to customize the title ?

Here is my Drupal module :

/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.
*/

Here is the screenshot of the current modal window :

Only local images are allowed.

Comments

geek-merlin’s picture