Issue #2409591 by pguillard, mayurjadhav, Artusamak, marcoscano, chris_h, ifrik, amateescu: Increase discoverability of view modes

8.2.x
Nathaniel Catchpole 2016-07-04 11:44:49 +01:00
parent 5e86905f1b
commit ee26b4b86a
3 changed files with 35 additions and 1 deletions

View File

@ -205,10 +205,12 @@ abstract class EntityDisplayFormBase extends EntityForm {
}
$form['modes']['display_modes_custom'] = array(
'#type' => 'checkboxes',
'#title' => $this->t('Use custom display settings for the following modes'),
'#title' => $this->t('Use custom display settings for the following @display_context modes', ['@display_context' => $this->displayContext]),
'#options' => $display_mode_options,
'#default_value' => $default,
);
// Provide link to manage display modes.
$form['modes']['display_modes_link'] = $this->getDisplayModesLink();
}
}
@ -790,6 +792,14 @@ abstract class EntityDisplayFormBase extends EntityForm {
*/
abstract protected function getDisplayModeOptions();
/**
* Returns a link to the form or view mode admin page.
*
* @return array
* An array of a form element to be rendered as a link.
*/
abstract protected function getDisplayModesLink();
/**
* Returns the region to which a row in the display overview belongs.
*

View File

@ -6,6 +6,7 @@ use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\PluginSettingsInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Drupal\field_ui\FieldUI;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -75,6 +76,17 @@ class EntityFormDisplayEditForm extends EntityDisplayFormBase {
return $this->entityManager->getFormModeOptions($this->entity->getTargetEntityTypeId());
}
/**
* {@inheritdoc}
*/
protected function getDisplayModesLink() {
return [
'#type' => 'link',
'#title' => t('Manage form modes'),
'#url' => Url::fromRoute('entity.entity_form_mode.collection'),
];
}
/**
* {@inheritdoc}
*/

View File

@ -6,6 +6,7 @@ use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\PluginSettingsInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Drupal\field_ui\FieldUI;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -108,6 +109,17 @@ class EntityViewDisplayEditForm extends EntityDisplayFormBase {
return $this->entityManager->getViewModeOptions($this->entity->getTargetEntityTypeId());
}
/**
* {@inheritdoc}
*/
protected function getDisplayModesLink() {;
return [
'#type' => 'link',
'#title' => t('Manage view modes'),
'#url' => Url::fromRoute('entity.entity_view_mode.collection'),
];
}
/**
* {@inheritdoc}
*/