protected function ProductAttributeTranslationFormTrait::renderOriginalValue in Commerce Core 8.2
Renders the given product attribute value in the original language.
Skips non-translatable fields. Skips all base fields other than the name.
Parameters
\Drupal\commerce_product\Entity\ProductAttributeValueInterface $value: The product attribute value.
Return value
array The render array.
1 call to ProductAttributeTranslationFormTrait::renderOriginalValue()
- ProductAttributeTranslationFormTrait::buildValuesForm in modules/
product/ src/ Form/ ProductAttributeTranslationFormTrait.php - Builds the translation form for product attribute values.
File
- modules/
product/ src/ Form/ ProductAttributeTranslationFormTrait.php, line 103
Class
- ProductAttributeTranslationFormTrait
- Provides common functionality for the product attribute translation forms.
Namespace
Drupal\commerce_product\FormCode
protected function renderOriginalValue(ProductAttributeValueInterface $value) {
$view_builder = $this->entityTypeManager
->getViewBuilder('commerce_product_variation');
$build = [];
foreach ($value
->getFieldDefinitions() as $field_name => $definition) {
if (!$definition
->isTranslatable()) {
continue;
}
if ($definition instanceof BaseFieldDefinition && $field_name != 'name') {
continue;
}
$build[$field_name] = $view_builder
->viewField($value
->get($field_name), [
'label' => 'above',
]);
}
return $build;
}