Commit 7c12f4e6 authored by bojanz's avatar bojanz

Add support to the price widget for displaying the help text. Remove the default help text.

parent 21038490
......@@ -97,6 +97,7 @@ class PriceDefaultWidget extends WidgetBase implements ContainerFactoryPluginInt
'#maxlength' => 255,
];
if (count($currencyCodes) == 1) {
$lastVisibleElement = 'amount';
$currencyCode = reset($currencyCodes);
$element['amount']['#field_suffix'] = $currencyCode;
$element['currency_code'] = [
......@@ -105,6 +106,7 @@ class PriceDefaultWidget extends WidgetBase implements ContainerFactoryPluginInt
];
}
else {
$lastVisibleElement = 'currency_code';
$element['currency_code'] = [
'#type' => 'select',
'#title' => $this->t('Currency'),
......@@ -114,6 +116,10 @@ class PriceDefaultWidget extends WidgetBase implements ContainerFactoryPluginInt
'#field_suffix' => '',
];
}
// Add the help text if specified.
if (!empty($element['#description'])) {
$element[$lastVisibleElement]['#field_suffix'] .= '<div class="description">' . $element['#description'] . '</div>';
}
return $element;
}
......
......@@ -11,7 +11,7 @@ field_name: commerce_price
entity_type: commerce_product
bundle: product
label: Price
description: 'Price field for products'
description: ''
required: false
translatable: false
default_value: { }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment