public function EntityInlineEntityFormController::tableFields in Inline Entity Form 7
Returns an array of fields used to represent an entity in the IEF table.
The fields can be either Field API fields or properties defined through hook_entity_property_info().
Modules can alter the output of this method through hook_inline_entity_form_table_fields_alter().
Parameters
$bundles: An array of allowed bundles for this widget.
Return value
An array of field information, keyed by field name. Allowed keys:
- type: 'field' or 'property',
- label: Human readable name of the field, shown to the user.
- weight: The position of the field relative to other fields.
Special keys for type 'field', all optional:
- formatter: The formatter used to display the field, or "hidden".
- settings: An array passed to the formatter. If empty, defaults are used.
- delta: If provided, limits the field to just the specified delta.
1 call to EntityInlineEntityFormController::tableFields()
4 methods override EntityInlineEntityFormController::tableFields()
- CommerceLineItemInlineEntityFormController::tableFields in includes/
commerce_line_item.inline_entity_form.inc - Overrides EntityInlineEntityFormController::tableFields().
- CommerceProductInlineEntityFormController::tableFields in includes/
commerce_product.inline_entity_form.inc - Overrides EntityInlineEntityFormController::tableFields().
- NodeInlineEntityFormController::tableFields in includes/
node.inline_entity_form.inc - Overrides EntityInlineEntityFormController::tableFields().
- TaxonomyTermInlineEntityFormController::tableFields in includes/
taxonomy_term.inline_entity_form.inc - Overrides EntityInlineEntityFormController::tableFields().
File
- includes/
entity.inline_entity_form.inc, line 93 - Defines the base inline entity form controller.
Class
- EntityInlineEntityFormController
- @file Defines the base inline entity form controller.
Code
public function tableFields($bundles) {
$info = entity_get_info($this->entityType);
$metadata = entity_get_property_info($this->entityType);
$fields = array();
if (!empty($info['entity keys']['label'])) {
$label_key = $info['entity keys']['label'];
$fields[$label_key] = array(
'type' => 'property',
'label' => $metadata ? $metadata['properties'][$label_key]['label'] : t('Label'),
'weight' => 1,
);
}
else {
$id_key = $info['entity keys']['id'];
$fields[$id_key] = array(
'type' => 'property',
'label' => $metadata ? $metadata['properties'][$id_key]['label'] : t('ID'),
'weight' => 1,
);
}
if (count($bundles) > 1) {
$bundle_key = $info['entity keys']['bundle'];
$fields[$bundle_key] = array(
'type' => 'property',
'label' => $metadata ? $metadata['properties'][$bundle_key]['label'] : t('Type'),
'weight' => 2,
);
}
return $fields;
}