Skip to content
Snippets Groups Projects
Commit f6d9ad47 authored by Eric Bremner's avatar Eric Bremner Committed by Kevin Paxman
Browse files

ISTWCMS-5880: adding allowed values function for type of media field

parent 1f347fc7
No related branches found
No related tags found
3 merge requests!284Feature/istwcms 5880 ebremner banners above,!274Draft: ISTWCMS-5551: fixing office hours display,!260Feature/istwcms 5668 a5kulkar rename references to publications
...@@ -9,11 +9,8 @@ field_name: field_uw_type_of_media ...@@ -9,11 +9,8 @@ field_name: field_uw_type_of_media
entity_type: node entity_type: node
type: list_string type: list_string
settings: settings:
allowed_values: allowed_values: { }
- allowed_values_function: '_uw_cfg_common_allowed_media_types'
value: image
label: Image
allowed_values_function: ''
module: options module: options
locked: false locked: false
cardinality: 1 cardinality: 1
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
...@@ -14,6 +15,7 @@ use Drupal\Core\Link; ...@@ -14,6 +15,7 @@ use Drupal\Core\Link;
use Drupal\Core\Render\Element; use Drupal\Core\Render\Element;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\fillpdf\Controller\HandlePdfController; use Drupal\fillpdf\Controller\HandlePdfController;
use Drupal\fillpdf\Form\FillPdfFormForm; use Drupal\fillpdf\Form\FillPdfFormForm;
use Drupal\media_library\MediaLibraryState; use Drupal\media_library\MediaLibraryState;
...@@ -1432,3 +1434,29 @@ function uw_cfg_common_preprocess_html(&$variables): void { ...@@ -1432,3 +1434,29 @@ function uw_cfg_common_preprocess_html(&$variables): void {
$variables['page']['#attached']['html_head'][] = [$noindex, 'noindex']; $variables['page']['#attached']['html_head'][] = [$noindex, 'noindex'];
} }
} }
/**
* Set dynamic allowed values for the type of media field.
*
* @param \Drupal\field\Entity\FieldStorageConfig $definition
* The field definition.
* @param \Drupal\Core\Entity\ContentEntityInterface|null $entity
* The entity being created if applicable.
* @param bool $cacheable
* Boolean indicating if the results are cacheable.
*
* @return array
* An array of possible key and value options.
*
* @see options_allowed_values()
*/
function _uw_cfg_common_allowed_media_types(
FieldStorageConfig $definition,
ContentEntityInterface $entity = NULL, $cacheable
) {
return [
'banner' => 'Banner images',
'image' => 'Image',
];
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment