Skip to content
Snippets Groups Projects

UI bugs

Merged Bálint Junkuncz requested to merge issue/custom_elements-3446302:3446302-ui-bugs into 3.x
1 unresolved thread
@@ -100,9 +100,8 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
@@ -100,9 +100,8 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public function buildForm(array $form, FormStateInterface $form_state) {
public function buildForm(array $form, FormStateInterface $form_state) {
$entity = $this->getEntity();
if ($this->isLayoutBuilderEnabled()) {
if ($this->isLayoutBuilderEnabled()) {
 
$entity = $this->getEntity();
$display = $this->entityDisplayRepository->getViewDisplay($entity->getTargetEntityTypeId(), $entity->getTargetBundle(), $entity->getMode());
$display = $this->entityDisplayRepository->getViewDisplay($entity->getTargetEntityTypeId(), $entity->getTargetBundle(), $entity->getMode());
$entity_type = $this->entityTypeManager->getDefinition($display->getTargetEntityTypeId());
$entity_type = $this->entityTypeManager->getDefinition($display->getTargetEntityTypeId());
$bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle';
$bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle';
@@ -126,20 +125,30 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
@@ -126,20 +125,30 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
return $form;
return $form;
}
}
$default_name = implode('-', [
return parent::buildForm($form, $form_state);
$entity->getTargetEntityTypeId(),
}
$entity->getTargetBundle(),
$entity->getMode(),
/**
]);
* {@inheritdoc}
 
*/
 
public function form(array $form, FormStateInterface $form_state) {
$form['custom_element_name'] = [
$form['custom_element_name'] = [
'#type' => 'textfield',
'#type' => 'textfield',
'#title' => $this->t('Custom element name'),
'#title' => $this->t('Custom element name'),
'#description' => $this->t('Defines the custom element which is going to be used for the display. There must be a matching implementation in the frontend to render the display.'),
'#description' => $this->t('Defines the custom element which is going to be used for the display. There must be a matching implementation in the frontend to render the display.'),
'#default_value' => $this->entity->getCustomElementName() ?? $default_name,
'#default_value' => $this->getEntity()->getCustomElementName(),
'#size' => 20,
'#size' => 20,
'#required' => TRUE,
'#required' => TRUE,
];
];
return parent::buildForm($form, $form_state);
 
$form = parent::form($form, $form_state);
 
 
// Remove "extra fields".
 
foreach (array_keys($this->getExtraFields()) as $field_id) {
 
unset($form['fields'][$field_id]);
 
}
 
 
return $form;
}
}
/**
/**
@@ -368,7 +377,7 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
@@ -368,7 +377,7 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
// When the plugin provides a form, show an edit button.
// When the plugin provides a form, show an edit button.
// But actually hide the form for now.
// But actually hide the form for now.
if (!empty($field_row['plugin']['settings_edit_form']['form'])) {
if (!empty($field_row['plugin']['settings_edit_form']['form']['settings'])) {
unset($field_row['plugin']['settings_edit_form']['form']);
unset($field_row['plugin']['settings_edit_form']['form']);
$field_row['settings_edit'] = $base_button + [
$field_row['settings_edit'] = $base_button + [
'#type' => 'image_button',
'#type' => 'image_button',
@@ -503,7 +512,7 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
@@ -503,7 +512,7 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
}
}
/**
/**
* {@inheritDoc}
* {@inheritdoc}
*/
*/
protected function getApplicablePluginOptions(FieldDefinitionInterface $field_definition) {
protected function getApplicablePluginOptions(FieldDefinitionInterface $field_definition) {
$options = $this->customElementFormatterPluginManager->getOptions($field_definition->getType());
$options = $this->customElementFormatterPluginManager->getOptions($field_definition->getType());
@@ -544,14 +553,14 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
@@ -544,14 +553,14 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
}
}
/**
/**
* {@inheritDoc}
* {@inheritdoc}
*/
*/
protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
protected function thirdPartySettingsForm(PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
return [];
return [];
}
}
/**
/**
* {@inheritDoc}
* {@inheritdoc}
*/
*/
protected function alterSettingsSummary(array &$summary, PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition) {}
protected function alterSettingsSummary(array &$summary, PluginSettingsInterface $plugin, FieldDefinitionInterface $field_definition) {}
Loading