Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wsdata
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
wsdata
Merge requests
!5
Issue
#3510517
: Call to Undefined Method.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3510517
: Call to Undefined Method.
issue/wsdata-3510517:3510517-call-to-undefined
into
3.0.x
Overview
0
Commits
4
Pipelines
4
Changes
1
Merged
Dhruv Mittal
requested to merge
issue/wsdata-3510517:3510517-call-to-undefined
into
3.0.x
1 month ago
Overview
0
Commits
4
Pipelines
4
Changes
1
Expand
Closes
#3510517
0
0
Merge request reports
Compare
3.0.x
version 3
749ad611
3 weeks ago
version 2
4328e315
1 month ago
version 1
ca648118
1 month ago
3.0.x (base)
and
latest version
latest version
aa8efb6e
4 commits,
3 weeks ago
version 3
749ad611
3 commits,
3 weeks ago
version 2
4328e315
2 commits,
1 month ago
version 1
ca648118
1 commit,
1 month ago
1 file
+
15
−
11
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
modules/wsdata_field/wsdata_field.module
+
15
−
11
Options
@@ -7,10 +7,12 @@
use
Drupal\Core\Entity\ContentEntityInterface
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Entity\EntityFormInterface
;
use
Drupal\Core\Field\FieldConfigInterface
;
use
Drupal\Core\Field\FieldStorageDefinitionInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Url
;
use
Drupal\field\Entity\FieldStorageConfig
;
use
Drupal\field_ui
\FieldUI
;
use
Drupal\wsdata_field
\Entity\WSFieldConfig
;
@@ -124,19 +126,21 @@ function wsdata_field_entity_load(array $entities, $entity_type_id) {
*/
function
wsdata_field_form_alter
(
&
$form
,
FormStateInterface
$form_state
,
$form_id
)
{
if
(
'node_delete_multiple_confirm_form'
!==
$form_id
&&
(
preg_match
(
'/^node_(.*)_edit_form/'
,
$form_id
)
||
preg_match
(
'/^node_(.*)_form/'
,
$form_id
)))
{
$entity
=
$form_state
->
getFormObject
()
->
getEntity
();
if
(
$entity
->
getEntityTypeId
()
==
'node'
)
{
$fields
=
$entity
->
getFieldDefinitions
();
foreach
(
$fields
as
$field
)
{
// Get the fields storage definitions.
$field_storage
=
$field
->
getFieldStorageDefinition
();
// Check if it has the custom storage flag set to true.
if
(
$field_storage
->
hasCustomStorage
())
{
// Check to make sure the object is of type FieldStorageConfig.
if
(
is_a
(
$field_storage
,
'Drupal\field\Entity\FieldStorageConfig'
))
{
$form_object
=
$form_state
->
getFormObject
();
// Ensure the form object has a getEntity method before calling it.
if
(
$form_object
instanceof
EntityFormInterface
)
{
$entity
=
$form_object
->
getEntity
();
if
(
$entity
instanceof
ContentEntityInterface
)
{
$fields
=
$entity
->
getFieldDefinitions
();
foreach
(
$fields
as
$field
)
{
// Get the fields storage definitions.
$field_storage
=
$field
->
getFieldStorageDefinition
();
// Check if custom storage flag set to true and
// the field storage object has correct class.
if
(
$field_storage
->
hasCustomStorage
()
&&
$field_storage
instanceof
FieldStorageConfig
)
{
// Fetch the wsfield config entity.
$wsfield_config
=
\Drupal
::
service
(
'entity_type.manager'
)
->
getStorage
(
'wsfield_config'
)
->
load
(
$field_storage
->
get
(
'field_name'
));
if
(
$wsfield_config
!=
NULL
)
{
if
(
$wsfield_config
!=
=
NULL
)
{
// Make the field hidden by adding a class.
$form
[
$field_storage
->
get
(
'field_name'
)][
'#attributes'
][
'class'
][]
=
'hidden'
;
}
Loading