Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Commits
f6d9ad47
Commit
f6d9ad47
authored
2 years ago
by
Eric Bremner
Committed by
Kevin Paxman
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5880: adding allowed values function for type of media field
parent
1f347fc7
No related branches found
No related tags found
3 merge requests
!284
Feature/istwcms 5880 ebremner banners above
,
!274
Draft: ISTWCMS-5551: fixing office hours display
,
!260
Feature/istwcms 5668 a5kulkar rename references to publications
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/install/field.storage.node.field_uw_type_of_media.yml
+2
-5
2 additions, 5 deletions
config/install/field.storage.node.field_uw_type_of_media.yml
uw_cfg_common.module
+28
-0
28 additions, 0 deletions
uw_cfg_common.module
with
30 additions
and
5 deletions
config/install/field.storage.node.field_uw_type_of_media.yml
+
2
−
5
View file @
f6d9ad47
...
...
@@ -9,11 +9,8 @@ field_name: field_uw_type_of_media
entity_type
:
node
type
:
list_string
settings
:
allowed_values
:
-
value
:
image
label
:
Image
allowed_values_function
:
'
'
allowed_values
:
{
}
allowed_values_function
:
'
_uw_cfg_common_allowed_media_types'
module
:
options
locked
:
false
cardinality
:
1
...
...
This diff is collapsed.
Click to expand it.
uw_cfg_common.module
+
28
−
0
View file @
f6d9ad47
...
...
@@ -7,6 +7,7 @@
use
Drupal\Component\Utility\Html
;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Entity\ContentEntityInterface
;
use
Drupal\Core\Entity\Display\EntityViewDisplayInterface
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Form\FormStateInterface
;
...
...
@@ -14,6 +15,7 @@ use Drupal\Core\Link;
use
Drupal\Core\Render\Element
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\Core\Url
;
use
Drupal\field\Entity\FieldStorageConfig
;
use
Drupal\fillpdf\Controller\HandlePdfController
;
use
Drupal\fillpdf\Form\FillPdfFormForm
;
use
Drupal\media_library
\MediaLibraryState
;
...
...
@@ -1432,3 +1434,29 @@ function uw_cfg_common_preprocess_html(&$variables): void {
$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'
,
];
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment