Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
entity_reference_display
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
entity_reference_display
Commits
e4c90fe7
Commit
e4c90fe7
authored
8 months ago
by
Ankit Debnath
Committed by
Eleo Basili
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3419382
by ankitdebnath, Mingsong, Anybody, eleonel: Drupal 10.2.x compatibility
parent
eb1a7195
No related branches found
No related tags found
1 merge request
!6
Issue #3419382 by ankitdebnath: Drupal 10.2.x compatibility fix in entity_reference_display.module file.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
entity_reference_display.module
+18
-10
18 additions, 10 deletions
entity_reference_display.module
with
18 additions
and
10 deletions
entity_reference_display.module
+
18
−
10
View file @
e4c90fe7
...
...
@@ -14,21 +14,29 @@ use Drupal\entity_reference_display\Plugin\Field\FieldFormatter\EntityReferenceR
*/
function
entity_reference_display_form_alter
(
&
$form
,
FormStateInterface
$form_state
,
$form_id
)
{
switch
(
$form_id
)
{
// Disable cardinality settings for 1 value limit.
case
'field_storage_config_edit_form'
:
/** @var \Drupal\field\Entity\FieldConfig $field_config */
$field_config
=
$form_state
->
getStorage
()[
'field_config'
];
// Only for display mode field.
if
(
$field_config
->
getType
()
==
'entity_reference_display'
)
{
// Disable editing by user.
$form
[
'cardinality_container'
][
'#disabled'
]
=
TRUE
;
// Remove states settings to disable JS widget.
unset
(
$form
[
'cardinality_container'
][
'cardinality_number'
][
'#states'
]);
}
// Disable editing and remove states for the cardinality settings.
_disable_cardinality_settings
(
$form
[
'cardinality_container'
]);
break
;
case
'field_config_edit_form'
:
// Disable editing and remove states for the cardinality settings nested deeper.
_disable_cardinality_settings
(
$form
[
'field_storage'
][
'subform'
][
'cardinality_container'
]);
break
;
}
}
/**
* Disable cardinality settings in a form section.
*
* @param array &$cardinality_container
* The cardinality section of the form.
*/
function
_disable_cardinality_settings
(
array
&
$cardinality_container
)
{
$cardinality_container
[
'#disabled'
]
=
TRUE
;
unset
(
$cardinality_container
[
'cardinality_number'
][
'#states'
]);
}
/**
* Implements hook_field_widget_info_alter().
*/
...
...
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