class EntityInlineTableViewModeForm in Inline Entity Form Table View Mode 8.2
Entity inline table view mode form handler.
Hierarchy
- class \Drupal\inline_entity_form\Form\EntityInlineForm implements InlineFormInterface uses StringTranslationTrait
- class \Drupal\ief_table_view_mode\Form\EntityInlineTableViewModeForm
Expanded class hierarchy of EntityInlineTableViewModeForm
3 files declare their use of EntityInlineTableViewModeForm
- IefTableViewModeTestTrait.php in tests/
src/ Traits/ IefTableViewModeTestTrait.php - ief_table_view_mode.module in ./
ief_table_view_mode.module - Defines a view mode to set up the columns of the table for the IEF widget.
- ViewModeIefTableTest.php in tests/
src/ Functional/ ViewModeIefTableTest.php
File
- src/
Form/ EntityInlineTableViewModeForm.php, line 11
Namespace
Drupal\ief_table_view_mode\FormView source
class EntityInlineTableViewModeForm extends EntityInlineForm {
const IEF_TABLE_VIEW_MODE_NAME = 'ief_table';
/**
* {@inheritdoc}
*/
public function getTableFields($bundles) {
$fields = parent::getTableFields($bundles);
$entity_type = $this->entityType
->id();
foreach ($bundles as $bundle) {
$display = EntityViewDisplay::load($entity_type . '.' . $bundle . '.' . self::IEF_TABLE_VIEW_MODE_NAME);
if (!$display || !$display
->status()) {
continue;
}
$old_fields = $fields;
$fields = [];
$field_definitions = $this->entityFieldManager
->getFieldDefinitions($entity_type, $bundle);
// Checking fields instances.
foreach ($field_definitions as $field_name => $field_definition) {
if (!$field_definition
->isDisplayConfigurable('view')) {
continue;
}
$display_options = $display
->getComponent($field_name);
if (empty($display_options)) {
continue;
}
$fields[$field_name] = [
'type' => 'field',
'label' => $field_definition
->getLabel(),
'display_options' => $display_options,
'weight' => $display_options['weight'],
];
}
// Default settings maybe has not registered any extra field.
foreach ($old_fields as $old_field_name => $old_field) {
if (isset($fields[$old_field_name])) {
continue;
}
$display_options = $display
->getComponent($old_field_name);
if (empty($display_options)) {
continue;
}
$fields[$old_field_name] = $old_field;
$fields[$old_field_name]['weight'] = $display_options['weight'];
}
$extra_fields = $this->entityFieldManager
->getExtraFields($entity_type, $bundle);
$extra_fields = isset($extra_fields['display']) ? $extra_fields['display'] : [];
foreach ($extra_fields as $extra_field_name => $extra_field) {
$display_options = $display
->getComponent($extra_field_name);
if (empty($display_options)) {
continue;
}
$fields[$extra_field_name] = [
'type' => 'callback',
'label' => is_string($extra_field['label']) ? $extra_field['label'] : $extra_field['label']
->render(),
'callback' => 'ief_table_view_mode_table_field_extra_field_callback',
'callback_arguments' => [
$extra_field_name,
],
'weight' => $display_options['weight'],
];
}
}
return $fields;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityInlineForm:: |
protected | property | The entity field manager. | |
EntityInlineForm:: |
protected | property | The entity type managed by this handler. | |
EntityInlineForm:: |
protected | property | The entity type manager. | |
EntityInlineForm:: |
protected | property | Module handler service. | |
EntityInlineForm:: |
protected | function | Builds an updated entity object based upon the submitted form values. | |
EntityInlineForm:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface:: |
|
EntityInlineForm:: |
public | function |
Delete permanently saved entities. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Builds the entity form. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Handles the submission of an entity form. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Validates the entity form. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Gets the label of the given entity. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Gets the entity type managed by this handler. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Gets the entity type labels (singular, plural). Overrides InlineFormInterface:: |
1 |
EntityInlineForm:: |
protected | function | Gets the form display for the given entity. | |
EntityInlineForm:: |
public | function |
Checks whether tabledrag should be enabled for the given table. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Saves the given entity. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public static | function | Cleans up the form state for a submitted entity form. | |
EntityInlineForm:: |
public | function | Constructs the inline entity form controller. | |
EntityInlineTableViewModeForm:: |
public | function |
Gets the columns used to represent an entity in the IEF table. Overrides EntityInlineForm:: |
|
EntityInlineTableViewModeForm:: |
constant | |||
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |