You are here

public function ProductVariationFieldRendererInterface::renderField in Commerce Core 8.2

Renders a single variation field.

Parameters

string $field_name: The field name.

\Drupal\commerce_product\Entity\ProductVariationInterface $variation: The product variation.

string|array $display_options: Can be either:

  • The name of a view mode. The field will be displayed according to the display settings specified for this view mode in the $field definition for the field in the entity's bundle. If no display settings are found for the view mode, the settings for the 'default' view mode will be used.
  • An array of display options. The following key/value pairs are allowed:
    • label: (string) Position of the label. The default 'field' theme implementation supports the values 'inline', 'above' and 'hidden'. Defaults to 'above'.
    • type: (string) The formatter to use. Defaults to the 'default_formatter' for the field type. The default formatter will also be used if the requested formatter is not available.
    • settings: (array) Settings specific to the formatter. Defaults to the formatter's default settings.
    • weight: (float) The weight to assign to the renderable element. Defaults to 0.

Return value

array The render array.

1 method overrides ProductVariationFieldRendererInterface::renderField()
ProductVariationFieldRenderer::renderField in modules/product/src/ProductVariationFieldRenderer.php
Renders a single variation field.

File

modules/product/src/ProductVariationFieldRendererInterface.php, line 59

Class

ProductVariationFieldRendererInterface
Renders variation fields.

Namespace

Drupal\commerce_product

Code

public function renderField($field_name, ProductVariationInterface $variation, $display_options = []);