You are here

public function BundleItemOrderItemInlineForm::getTableFields in Commerce Product Bundle 8

Gets the columns used to represent an entity in the IEF table.

Modules can alter the output of this method through hook_inline_entity_form_table_fields_alter().

Parameters

string[] $bundles: An array of allowed bundles for this widget.

Return value

array An array of data about table columns keyed by column name. Each column is represented by an associative array containing the following keys:

  • type: One of 'label', 'field' or 'callback', which indicates how this column should be handled:

    • 'label': The entity's label.
    • 'field': A field value from the entity. The name of the field is given by the key in this array.
    • 'callback': A callback, given by the 'callback' property.

    @see template_preprocess_inline_entity_form_entity_table() for the handling of these.

  • label: the title of the table field's column in the IEF table.
  • weight: the sort order of the column in the IEF table.
  • display_options: (optional) used for 'field' type table columns, an array of display settings. See EntityViewBuilderInterface::viewField().
  • callback: for 'callback' type table columns, a callable that returns a renderable array.
  • callback_arguments: (optional) an array of additional arguments to pass to the callback. The entity and the theme variables are always passed as as the first two arguments.

Overrides EntityInlineForm::getTableFields

File

src/Form/BundleItemOrderItemInlineForm.php, line 28

Class

BundleItemOrderItemInlineForm
Defines the inline form for order items.

Namespace

Drupal\commerce_product_bundle\Form

Code

public function getTableFields($bundles) {
  $fields = parent::getTableFields($bundles);
  $fields['purchased_entity'] = [
    'type' => 'field',
    'label' => t('Purchased Entity'),
    'weight' => 2,
  ];
  $fields['unit_price'] = [
    'type' => 'field',
    'label' => t('Unit price'),
    'weight' => 2,
  ];
  $fields['quantity'] = [
    'type' => 'field',
    'label' => t('Quantity'),
    'weight' => 3,
  ];
  return $fields;
}