You are here

public function QuantityInlineForm::getTableFields in farmOS 2.x

File

modules/core/quantity/src/Form/QuantityInlineForm.php, line 19

Class

QuantityInlineForm
Render the quantity entity in quantity inline entity forms.

Namespace

Drupal\quantity\Form

Code

public function getTableFields($bundles) {

  // Trick IEF into thinking there are two bundles.
  // This will always render the "Quantity type" field in the table.
  if (count($bundles) == 1) {
    $bundles[] = $bundles[0];
  }

  // Get parent fields.
  $fields = parent::getTableFields($bundles);

  // Remove the label field.
  unset($fields['label']);

  // Add a field that renders the quantity entity.
  $fields['quantity'] = [
    'type' => 'callback',
    'label' => $this
      ->t('Quantity'),
    'weight' => 1,
    'callback' => [
      $this,
      'renderQuantity',
    ],
  ];
  return $fields;
}