我在Drupal 8.6和Bootstrap 3.3.7上有一个网站
我创建了一个自定义模块,供客户在下订单时接受商店的条款和条件。
这将显示指向付款前复选框的链接,以在模式窗口中显示条款和条件。
当我在这里下订单时,日志中会显示警告(很抱歉,我的代码太长了,无法在此处发布):
https://pastebin.com/1p5m1Ved
https://pastebin.com/XYbqDJje
https://pastebin.com/P93bStKh
这是造成问题的文件:
<?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;
}
}
我的自定义模块出了什么问题以及如何解决该问题?谢谢