function ief_table_view_mode_field_widget_third_party_settings_form in Inline Entity Form Table View Mode 8
Implements hook_field_widget_third_party_settings_form().
File
- ./
ief_table_view_mode.module, line 170 - Defines a view mode to set up the columns of the table for the IEF widget.
Code
function ief_table_view_mode_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state) {
$element = array();
if ($plugin
->getPluginId() != 'inline_entity_form_complex') {
return $element;
}
$entity_type = $field_definition
->getSetting('target_type');
$entityManager = \Drupal::service('entity.manager');
$entityDefinition = $entityManager
->getDefinition($entity_type);
$element['ief_table_view_mode'] = array(
'#type' => 'container',
);
$field_ui_base_route = $entityDefinition
->get('field_ui_base_route');
if (!$field_ui_base_route) {
$message = \Drupal::translation()
->translate('It is not posible to add fields to the table widget because the %entity_name entity does not have Manage display.', array(
'%entity_name' => $entityDefinition
->getLabel(),
));
$element['ief_table_view_mode']['info'] = array(
'#markup' => $message,
);
return $element;
}
$message = \Drupal::translation()
->translate('It is posible to add fields to the table widget, creatring and activating the view mode %name_view_name. Then go to Manage display of %entity_name entity.', array(
'%name_view_name' => $entity_type . '.' . IEF_TABLE_VIEW_MODE_NAME,
'%entity_name' => $entityDefinition
->getLabel(),
));
$element['ief_table_view_mode']['info'] = array(
'#markup' => $message,
);
return $element;
}